小编hab*_*kuk的帖子

更新到Django 1.8 - AttributeError:django.test.TestCase没有属性'cls_atomics'

我将Django 1.7项目更新为Django 1.8,现在运行测试时出现错误(这是子类django.test.TestCase).

Traceback (most recent call last):
  File "env\lib\site-packages\django\test\testcases.py", line 962, in tearDownClass
cls._rollback_atomics(cls.cls_atomics)
  AttributeError: type object 'SomeTests' has no attribute 'cls_atomics'
Run Code Online (Sandbox Code Playgroud)

如果我通过测试进行调试,我可以毫无问题地遍历所有行,但是在最后一行之后抛出异常.

这是一个示例测试:

import django
import unittest
from django.test import TestCase
import logging
import sys
from builtins import classmethod, isinstance

class ATestTests(TestCase):

    @classmethod
    def setUpClass(cls):
        django.setup()
        logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)


    def setUp(self):
        self._app = Application(name="a")


    def testtest(self):

        self.assertIsNotNone(self._app)
Run Code Online (Sandbox Code Playgroud)

我的环境:

astroid==1.3.4
colorama==0.3.3
defusedxml==0.4.1
Django==1.8
django-extensions==1.5.2
django-filter==0.9.2
djangorestframework==3.0.5
djangorestframework-xml==1.0.1
eight==0.3.0
future==0.11.4
logilab-common==0.63.2
Markdown==2.5.2
pylint==1.4.1
python-dateutil==2.4.1
python-mimeparse==0.1.4
six==1.9.0
xmltodict==0.9.2
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

django python-3.x django-1.8

60
推荐指数
3
解决办法
7710
查看次数

Visual Studio 2015和IFormatProvider中的字符串插值(CA1305)

Visual Studio 2015中的新字符串插值样式是这样的:

Dim s = $"Hello {name}"
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用它,代码分析告诉我,我打破CA1305:指定IFormatProvider

在过去,我这样做:

Dim s = String.Format(Globalization.CultureInfo.InvariantCulture, "Hello {0}", name)
Run Code Online (Sandbox Code Playgroud)

但是如何用新风格来完成呢?

我必须提一下,我正在寻找.Net 4.5.2的解决方案(.Net 4.6 dcastro有答案)

.net c# vb.net string.format visual-studio-2015

29
推荐指数
3
解决办法
6077
查看次数

为什么将"(Double.MinValue + 1)> Double.MinValue"评估为false?

我第一次尝试这个(在vb.net中)

(Double.MinValue + Double.Epsilon) > Double.MinValue
Run Code Online (Sandbox Code Playgroud)

但评估结果为假.然后我尝试了这个

(Double.MinValue + 999999999999999999) > Double.MinValue
Run Code Online (Sandbox Code Playgroud)

也评估为假.

为什么?

.net double

11
推荐指数
1
解决办法
231
查看次数

'.NET Framework 3.5 SP1客户端配置文件'先决条件

我有一个.Net安装项目,并将先决条件的安装位置设置为"从与我的应用程序相同的位置下载".

我从https://www.microsoft.com/downloads/en/details.aspx?FamilyID=992cffcb-f8ce-41d9-8bd6-31f3e216285c下载了"Microsoft .NET Framework Client Profile Offline Installer" 并将其放在目录中:

C:\ Program Files(x86)\ Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35Client和C:\ Program Files(x86)\ Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFx35Client

但我仍然收到错误消息"先决条件尚未设置为'组件供应商的网站',并且".NET Framework 3.5 SP1客户端配置文件"中的文件'DotNetFx35Client\DotNetFx35ClientSetup.exe'无法位于磁盘上."

任何的想法?

我有Windows 7和Visual Studio 2010 ...

谢谢!斯特凡

installation prerequisites visual-studio-2010 .net-3.5 .net-client-profile

8
推荐指数
1
解决办法
7812
查看次数

WPF的BitmapCache尚未完全清除

我们有一个带有用户控件的WPF页面,我们使用BitmapCache - 当我们尝试通过使用空路径(New Path())更新属性(数据绑定)来清除此元素时,它不会被完全刷新/清除.如果我稍微更改窗口大小,则BitmapCache处于活动状态的区域将被完全清除.

清除/刷新使用BitmapCache的元素有什么特别的事吗?

这是我们的代码:

    <me:ScrollViewer
    RenderedWaves="{Binding RenderedWaves}"
    ItemTemplate="{DynamicResource DataTemplateForWaveItem}" 
    ItemsPanel="{DynamicResource ItemsPanelTemplateForWaveItems}" 
    CacheMode="BitmapCache" />
Run Code Online (Sandbox Code Playgroud)

我以为我修好了,但不是每次都有效......

此代码设置路径不会立即更新BitmapCache:

Protected WriteOnly Property SetGraph As Path
 Set(value As Path)
    If value Is Nothing Then value = GetEmptyPath()
    _graph = value
    OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph))
 End Set
End Property
Run Code Online (Sandbox Code Playgroud)

此代码有时会更新它:

Protected WriteOnly Property SetGraph As Path
Set(value As Path)
    UIDispatcherLocator.UIDispatcher.Invoke(Sub()
                                                If value Is Nothing Then value = GetEmptyPath()
                                                _graph = value
                                            End Sub, Threading.DispatcherPriority.Background)
    OnPropertyChanged(New PropertyChangedEventArgs(PropertyNameGraph))
End Set
End Property
Run Code Online (Sandbox Code Playgroud)

.net wpf rendering path bitmap

6
推荐指数
1
解决办法
947
查看次数

当我必须手动关闭旁路功能时,为什么要使用强名称程序集?

Microsoft Code Analysis鼓励我强烈命名所有程序集.但根据微软的说法,我必须手动禁用它们被检查的"旁路功能".

因此,自.NET Framework 3.5版Service Pack 1强名称未经过验证.

为什么我仍然要用强名称签署我的集会?

谢谢!斯特凡

.net strongname

6
推荐指数
1
解决办法
604
查看次数

Popen.communicate() 抛出 UnicodeDecodeError

我有这个代码:

def __executeCommand(self, command: str, input: str = None) -> str:
    p = sub.Popen(command, stdout=sub.PIPE, stderr=sub.PIPE, stdin=sub.PIPE, universal_newlines=True)
    p.stdin.write(input)
    output, error = p.communicate()
    if (len(errors) > 0):
        raise EnvironmentError("Could not generate the key: " + error)
    elif (p.returncode != 0):
        raise EnvironmentError("Could not generate the key. Return Value: " + p.returncode)
    return output
Run Code Online (Sandbox Code Playgroud)

我在该行中收到 UnicodeDecodeError output, error = p.communicate()

Traceback (most recent call last):
  File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
    self.run()
  File "C:\Python34\lib\threading.py", line 869, in run
    self._target(*self._args, **self._kwargs) …
Run Code Online (Sandbox Code Playgroud)

python unicode subprocess python-3.x

4
推荐指数
1
解决办法
8612
查看次数

Python 初学者 - &lt;bound method ... of &lt;... object at 0x0000000005EAAEB8&gt;&gt; 从哪里来?

我有一堂课

class ActivationResult(object):

    def __init__(self, successful : bool):
        self._successful = successful

    def getSuccessful(self) -> bool:
        return self._successful
Run Code Online (Sandbox Code Playgroud)

还有一个测试

def testSuccessfulFromCreate(self):

    target = ActivationResult(True)

    self.assertEquals(target._successful, True)
    self.assertEquals(target.getSuccessful, True)
Run Code Online (Sandbox Code Playgroud)

第一个断言很好,但第二个断言失败 AssertionError: <bound method ActivationResult.getSuccess[84 chars]EB8>> != True

当我尝试打印它时,也会发生同样的事情。为什么?

python properties

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