小编Mat*_*our的帖子

清理旧的远程git分支机构

这是我的git工作流程.

我在两台不同的计算机(A和B)上工作,并在dropbox目录中存储一个公共git远程.

假设我有两个分支主人和开发人员.两者都在追踪他们的远程对手origin/master和origin/devel.

现在,在计算机A上,我删除了分支开发 - 本地和远程 - 如下所示:

git push origin :heads/devel

git branch -d devel
Run Code Online (Sandbox Code Playgroud)

现在如果我git branch -a在电脑A上做,我明白了

master
origin/HEAD
origin/master
Run Code Online (Sandbox Code Playgroud)

我现在去电脑B.做git fetch.我可以删除本地开发分支

git branch -d devel
Run Code Online (Sandbox Code Playgroud)

但我无法删除远程开发分支.

git push origin :heads/devel

error: unable to push to unqualified destination: heads/proxy3d
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
fatal: The remote end hung up unexpectedly …
Run Code Online (Sandbox Code Playgroud)

git git-branch

646
推荐指数
7
解决办法
30万
查看次数

断言没有使用Mock调用函数/方法

我正在使用Mock库来测试我的应用程序,但我想断言某些函数没有被调用.模拟文档讨论像mock.assert_called_with和的方法mock.assert_called_once_with,但我没有发现任何类似mock.assert_not_called或与确认模拟相关的东西没有调用.

我可以使用类似下面的东西,虽然它看起来不酷也不像pythonic:

def test_something:
    # some actions
    with patch('something') as my_var:
        try:
            # args are not important. func should never be called in this test
            my_var.assert_called_with(some, args)
        except AssertionError:
            pass  # this error being raised means it's ok
    # other stuff
Run Code Online (Sandbox Code Playgroud)

任何想法如何实现这一目标?

谢谢你的帮助 :)

python unit-testing mocking python-mock

117
推荐指数
5
解决办法
7万
查看次数

Linq与众不同 - 伯爵

我期待对对象的示例列表执行查询

Date     Username

01/01/2011 james
01/01/2011 jamie
01/01/2011 alex
01/01/2011 james
02/01/2011 matt
02/01/2011 jamie
02/01/2011 alex
02/01/2011 james
02/01/2011 james
02/01/2011 lucy
02/01/2011 alex
03/01/2011 james
03/01/2011 bob
03/01/2011 bob
03/01/2011 james
03/01/2011 james
04/01/2011 alex
04/01/2011 alex
04/01/2011 alex
Run Code Online (Sandbox Code Playgroud)

我想使用linq查询具有唯一用户登录数的日期列表.

例如:

01/01/2011 - 3
02/01/2011 - 5
03/01/2011 - 2
04/01/2011 - 1
Run Code Online (Sandbox Code Playgroud)

我试过了一些linq语句测试,但这些都没有给我想要的结果.我最接近的是给我不同的日期,但有所有用户的数量.

任何帮助将不胜感激.

c# linq

61
推荐指数
4
解决办法
8万
查看次数

睡眠方法和多线程的产量方法有什么区别?

当遇到调用时当前正在执行线程,[sleep][1]();然后线程立即进入休眠状态,其中[yield][2]();线程进入可运行状态/就绪状态

java multithreading

51
推荐指数
5
解决办法
14万
查看次数

Python多处理优雅退出如何?

import multiprocessing
import time

class testM(multiprocessing.Process):

    def __init__(self):
        multiprocessing.Process.__init__(self)
        self.exit = False

    def run(self):
        while not self.exit:
            pass
        print "You exited!"
        return

    def shutdown(self):
        self.exit = True
        print "SHUTDOWN initiated"

    def dostuff(self):
        print "haha", self.exit


a = testM()
a.start()
time.sleep(3)
a.shutdown()
time.sleep(3)
print a.is_alive()
a.dostuff()
exit()
Run Code Online (Sandbox Code Playgroud)

我只是想知道为什么上面的代码没有真正打印"你退出".我究竟做错了什么?如果是这样,有人可能会指出我正确退出的正确方法吗?(我不是指process.terminate或kill)

python multiprocessing

45
推荐指数
1
解决办法
5万
查看次数

实体框架4获取插入记录的主键ID

我正在使用Entity Framework将一行插入我的sql数据库.如果我要使用存储过程,那么我将能够返回我插入的记录的主键.

我是否能够使用实体框架返回最后一个插入的最后一条记录的PK?

.net c# entity-framework

35
推荐指数
2
解决办法
4万
查看次数

Devexpress或Telerik Controls比较

我正在考虑购买dev express或telerik以帮助开发我们的应用程序.

我们主要是一个asp.net服装,但我们开始越来越多地使用silverlight和mvc.

我想知道人们的想法:

  • 功能集
  • 便于使用
  • 文档
  • 定价和许可

c# asp.net devexpress telerik

33
推荐指数
5
解决办法
5万
查看次数

Python新手@patch装饰器问题

我尝试通过使用@patch以下方法修改测试方法来修补提供程序类:

class TestMyUnit(unittest.TestCase):
...
@patch(provider.Provider,autospec=True)
def test_init(self, mock_provider):
    pass
Run Code Online (Sandbox Code Playgroud)

但是,当我运行测试时,我收到错误:

*@patch(provider.Provider)*  
*File "build\bdist.win32\egg\mock.py", line 1518, in patch*  
*getter, attribute = \_get\_target(target)*  
*File "build\bdist.win32\egg\mock.py", line 1367, in \_get\_target*  
*target, attribute = target.rsplit('.', 1)*  
*AttributeError: class Provider has no attribute 'rsplit'*  
*ERROR: Module: test\_my\_unit could not be imported (file: C:\dev\src\test\_my\_unit.py).*
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

python patch mocking

30
推荐指数
1
解决办法
1万
查看次数

Kickstarter是否有公共API?

我正在寻找一个kickstarter API(但没有运气找到一个).

我确实在github上看到了一个抓取API,但这并不是我想要的.

api kickstarter

30
推荐指数
3
解决办法
3万
查看次数

没有名为urls的模块

我正在关注Django教程,我在第3部分的末尾,在解耦URLconfs,http: //docs.djangoproject.com/en/1.1/intro/tutorial03/#intro-tutorial03,我是获取"No module named urls"错误消息.

当我改变时:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('mysite.polls.views',
    (r'^polls/$', 'index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$', 'results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', 'vote'),
    (r'^admin/', include(admin.site.urls)),
)
Run Code Online (Sandbox Code Playgroud)

至:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^polls/', include('mysite.polls.urls')),
    (r'^admin/', include(admin.site.urls)),
)
Run Code Online (Sandbox Code Playgroud)

我换include('mysite.polls.urls')),include(mysite.polls.urls)),,但它仍然没有用.

如何解决这个问题呢?

更新2:在mysite/polls/urls.py是

from django.conf.urls.defaults import *

urlpatterns = patterns('mysite.polls.views',
    (r'^$', 'index'),
    (r'^(?P<poll_id>\d+)/$', 'detail'),
    (r'^(?P<poll_id>\d+)/results/$', 'results'),
    (r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
Run Code Online (Sandbox Code Playgroud)

更新4:整个项目在

http://www.mediafire.com/?t1jvomjgjz1

python django

23
推荐指数
4
解决办法
6万
查看次数