01-fix-tests.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. --- contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py (index)
  2. +++ contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py (working tree)
  3. @@ -15,1 +15,1 @@
  4. -def testIReadMapping(self, inst, state, absent):
  5. +def _testIReadMapping(self, inst, state, absent):
  6. @@ -28,1 +28,1 @@ def testIReadMapping(self, inst, state, absent):
  7. -def test_keys(self, inst, state):
  8. +def _test_keys(self, inst, state):
  9. @@ -35,1 +35,1 @@ def testIReadMapping(self, inst, state, absent):
  10. -def test_iter(self, inst, state):
  11. +def _test_iter(self, inst, state):
  12. @@ -45,1 +45,1 @@ def testIReadMapping(self, inst, state, absent):
  13. -def test_values(self, inst, state):
  14. +def _test_values(self, inst, state):
  15. @@ -50,1 +50,1 @@ def testIReadMapping(self, inst, state, absent):
  16. -def test_items(self, inst, state):
  17. +def _test_items(self, inst, state):
  18. @@ -60,1 +60,1 @@ def testIReadMapping(self, inst, state, absent):
  19. -def test___len__(self, inst, state):
  20. +def _test___len__(self, inst, state):
  21. @@ -65,5 +65,5 @@ def testIReadMapping(self, inst, state, absent):
  22. -def testIEnumerableMapping(self, inst, state):
  23. - test_keys(self, inst, state)
  24. - test_items(self, inst, state)
  25. - test_values(self, inst, state)
  26. - test___len__(self, inst, state)
  27. +def _testIEnumerableMapping(self, inst, state):
  28. + _test_keys(self, inst, state)
  29. + _test_items(self, inst, state)
  30. + _test_values(self, inst, state)
  31. + _test___len__(self, inst, state)
  32. @@ -68,1 +68,1 @@ class BaseTestIReadMapping(object):
  33. - testIReadMapping(self, inst, state, absent)
  34. + _testIReadMapping(self, inst, state, absent)
  35. @@ -77,25 +77,25 @@ class BaseTestIEnumerableMapping(BaseTestIReadMapping):
  36. # Return the keys of the mapping object
  37. inst = self._IEnumerableMapping__sample()
  38. state = self._IEnumerableMapping__stateDict()
  39. - test_keys(self, inst, state)
  40. + _test_keys(self, inst, state)
  41. def test_values(self):
  42. # Return the values of the mapping object
  43. inst = self._IEnumerableMapping__sample()
  44. state = self._IEnumerableMapping__stateDict()
  45. - test_values(self, inst, state)
  46. + _test_values(self, inst, state)
  47. def test_items(self):
  48. # Return the items of the mapping object
  49. inst = self._IEnumerableMapping__sample()
  50. state = self._IEnumerableMapping__stateDict()
  51. - test_items(self, inst, state)
  52. + _test_items(self, inst, state)
  53. def test___len__(self):
  54. # Return the number of items
  55. inst = self._IEnumerableMapping__sample()
  56. state = self._IEnumerableMapping__stateDict()
  57. - test___len__(self, inst, state)
  58. + _test___len__(self, inst, state)
  59. def _IReadMapping__stateDict(self):
  60. return self._IEnumerableMapping__stateDict()
  61. --- contrib/python/zope.interface/py3/zope/interface/tests/__init__.py (index)
  62. +++ contrib/python/zope.interface/py3/zope/interface/tests/__init__.py (working tree)
  63. @@ -23,1 +23,1 @@ class OptimizationTestMixin(object):
  64. - def test_optimizations(self):
  65. + def _test_optimizations(self):
  66. --- contrib/python/zope.interface/py3/zope/interface/tests/dummy.py (index)
  67. +++ contrib/python/zope.interface/py3/zope/interface/tests/dummy.py (working tree)
  68. @@ -14,1 +14,1 @@
  69. -from zope.interface.tests.idummy import IDummyModule
  70. +from .idummy import IDummyModule
  71. --- contrib/python/zope.interface/py3/zope/interface/tests/test_adapter.py (index)
  72. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_adapter.py (working tree)
  73. @@ -15,1 +15,1 @@
  74. -from zope.interface.tests import OptimizationTestMixin
  75. +from __tests__.tests import OptimizationTestMixin
  76. @@ -1640,1 +1640,1 @@ class AdapterLookupBaseTests(unittest.TestCase):
  77. - from zope.interface.tests import MissingSomeAttrs
  78. + from __tests__.tests import MissingSomeAttrs
  79. --- contrib/python/zope.interface/py3/zope/interface/tests/test_advice.py (index)
  80. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_advice.py (working tree)
  81. @@ -35,1 +35,1 @@ from zope.interface._compat import _skip_under_py3k
  82. - from zope.interface.tests import advisory_testing
  83. + from . import advisory_testing
  84. @@ -43,1 +43,1 @@ class FrameInfoTest(unittest.TestCase):
  85. - from zope.interface.tests import advisory_testing
  86. + from . import advisory_testing
  87. --- contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py (index)
  88. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_declarations.py (working tree)
  89. @@ -18,4 +18,4 @@ import unittest
  90. -from zope.interface.tests import MissingSomeAttrs
  91. -from zope.interface.tests import OptimizationTestMixin
  92. -from zope.interface.tests import SubclassableMixin
  93. -from zope.interface.tests.test_interface import \
  94. +from __tests__.tests import MissingSomeAttrs
  95. +from __tests__.tests import OptimizationTestMixin
  96. +from __tests__.tests import SubclassableMixin
  97. +from __tests__.tests.test_interface import \
  98. @@ -302,1 +302,1 @@ class DeclarationTests(EmptyDeclarationTests):
  99. - from zope.interface.tests.test_ro import C3Setting
  100. + from __tests__.tests.test_ro import C3Setting
  101. @@ -324,1 +324,1 @@ class DeclarationTests(EmptyDeclarationTests):
  102. - from zope.interface.tests.test_ro import C3Setting
  103. + from __tests__.tests.test_ro import C3Setting
  104. @@ -681,1 +681,1 @@ class Test_implementedByFallback(unittest.TestCase):
  105. - 'zope.interface.tests.test_declarations.foo')
  106. + '__tests__.tests.test_declarations.foo')
  107. @@ -697,1 +697,1 @@ class Test_implementedByFallback(unittest.TestCase):
  108. - 'zope.interface.tests.test_declarations.Foo')
  109. + '__tests__.tests.test_declarations.Foo')
  110. @@ -1034,1 +1034,1 @@ class Test_classImplements(_ImplementsTestMixin, unittest.TestCase):
  111. - from zope.interface.tests.test_ro import C3Setting
  112. + from __tests__.tests.test_ro import C3Setting
  113. @@ -1178,1 +1178,1 @@ class Test_implementer(Test_classImplements):
  114. - spec.__name__, 'zope.interface.tests.test_declarations.?'
  115. + spec.__name__, '__tests__.tests.test_declarations.?'
  116. @@ -1374 +1374 @@ class TestProvidesClassRepr(unittest.TestCase):
  117. - from zope.interface.tests import dummy
  118. + from . import dummy
  119. @@ -1379,1 +1379,1 @@ class TestProvidesClassRepr(unittest.TestCase):
  120. - "sys.modules['zope.interface.tests.dummy'], "
  121. + "sys.modules['__tests__.tests.dummy'], "
  122. @@ -1387 +1387 @@ class TestProvidesClassRepr(unittest.TestCase):
  123. - from zope.interface.tests import dummy
  124. + from . import dummy
  125. @@ -1399,1 +1399,1 @@ class TestProvidesClassRepr(unittest.TestCase):
  126. - from zope.interface.tests import dummy
  127. + from __tests__.tests import dummy
  128. @@ -1425 +1425 @@ class TestProvidesClassRepr(unittest.TestCase):
  129. + "directlyProvides(sys.modules['__tests__.tests.dummy'], IFoo)"
  130. - "directlyProvides(sys.modules['zope.interface.tests.dummy'], IFoo)"
  131. @@ -1450,1 +1450,1 @@ class TestProvidesClassRepr(unittest.TestCase):
  132. - "sys.modules['zope.interface.tests.dummy'], "
  133. + "sys.modules['__tests__.tests.dummy'], "
  134. @@ -1436,2 +1436,2 @@ class TestProvidesClassRepr(unittest.TestCase):
  135. - "directlyProvides(('zope.interface.tests.dummy', "
  136. - "'zope.interface.tests.test_declarations'), "
  137. + "directlyProvides(('__tests__.tests.dummy', "
  138. + "'__tests__.tests.test_declarations'), "
  139. @@ -2074,1 +2074,1 @@ class Test_moduleProvides(unittest.TestCase):
  140. - globs = {'__name__': 'zope.interface.tests.foo',
  141. + globs = {'__name__': '__tests__.tests.tests.foo',
  142. @@ -2103,1 +2103,1 @@ class Test_moduleProvides(unittest.TestCase):
  143. - globs = {'__name__': 'zope.interface.tests.foo',
  144. + globs = {'__name__': '__tests__.tests.tests.foo',
  145. @@ -2116,1 +2116,1 @@ class Test_moduleProvides(unittest.TestCase):
  146. - globs = {'__name__': 'zope.interface.tests.foo',
  147. + globs = {'__name__': '__tests__.tests.tests.foo',
  148. --- contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (index)
  149. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_exceptions.py (working tree)
  150. @@ -36,1 +36,1 @@ class DoesNotImplementTests(unittest.TestCase):
  151. - "zope.interface.tests.test_exceptions.IDummy: "
  152. + "__tests__.tests.test_exceptions.IDummy: "
  153. @@ -45,1 +45,1 @@ class DoesNotImplementTests(unittest.TestCase):
  154. - "zope.interface.tests.test_exceptions.IDummy: "
  155. + "__tests__.tests.test_exceptions.IDummy: "
  156. @@ -65,1 +65,1 @@ class BrokenImplementationTests(unittest.TestCase):
  157. - 'zope.interface.tests.test_exceptions.IDummy: '
  158. + '__tests__.tests.test_exceptions.IDummy: '
  159. @@ -73,1 +73,1 @@ class BrokenImplementationTests(unittest.TestCase):
  160. - 'zope.interface.tests.test_exceptions.IDummy: '
  161. + '__tests__.tests.test_exceptions.IDummy: '
  162. @@ -161,1 +161,1 @@ class MultipleInvalidTests(unittest.TestCase):
  163. - "zope.interface.tests.test_exceptions.IDummy:\n"
  164. + "__tests__.tests.test_exceptions.IDummy:\n"
  165. @@ -177,1 +177,1 @@ class MultipleInvalidTests(unittest.TestCase):
  166. - "<InterfaceClass zope.interface.tests.test_exceptions.IDummy>,"
  167. + "<InterfaceClass __tests__.tests.test_exceptions.IDummy>,"
  168. --- contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py (index)
  169. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_interface.py (working tree)
  170. @@ -24,4 +24,4 @@
  171. -from zope.interface.tests import CleanUp
  172. -from zope.interface.tests import MissingSomeAttrs
  173. -from zope.interface.tests import OptimizationTestMixin
  174. -from zope.interface.tests import SubclassableMixin
  175. +from __tests__.tests import CleanUp
  176. +from __tests__.tests import MissingSomeAttrs
  177. +from __tests__.tests import OptimizationTestMixin
  178. +from __tests__.tests import SubclassableMixin
  179. @@ -1036,1 +1036,1 @@ class InterfaceClassTests(unittest.TestCase):
  180. - hash(('HashMe', 'zope.interface.tests.test_interface'))
  181. + hash(('HashMe', '__tests__.tests.test_interface'))
  182. @@ -1076,2 +1076,2 @@ class InterfaceClassTests(unittest.TestCase):
  183. - one = self._makeOne('IName', __module__='zope.interface.tests.one')
  184. - other = self._makeOne('IName', __module__='zope.interface.tests.other')
  185. + one = self._makeOne('IName', __module__='__tests__.tests.one')
  186. + other = self._makeOne('IName', __module__='__tests__.tests.other')
  187. --- contrib/python/zope.interface/py3/zope/interface/tests/test_odd_declarations.py (index)
  188. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_odd_declarations.py (working tree)
  189. @@ -18,1 +18,1 @@ classic ExtensionClass classes and instances.
  190. -from zope.interface.tests import odd
  191. +from . import odd
  192. --- contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py (index)
  193. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_sorting.py (working tree)
  194. @@ -41,1 +41,1 @@ class Test(unittest.TestCase):
  195. - from zope.interface.tests.m1 import I1 as m1_I1
  196. + from .m1 import I1 as m1_I1
  197. --- contrib/python/zope.interface/py3/zope/interface/tests/test_verify.py (index)
  198. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_verify.py (working tree)
  199. @@ -614,2 +614,2 @@ class Test_verifyObject(Test_verifyClass):
  200. - from zope.interface.tests import dummy
  201. - from zope.interface.tests.idummy import IDummyModule
  202. + from . import dummy
  203. + from .idummy import IDummyModule
  204. @@ -620,1 +620,1 @@ class Test_verifyObject(Test_verifyClass):
  205. - from zope.interface.tests import dummy
  206. + from . import dummy
  207. --- contrib/python/zope.interface/py3/zope/interface/tests/test_ro.py (index)
  208. +++ contrib/python/zope.interface/py3/zope/interface/tests/test_ro.py (working tree)
  209. @@ -221,218 +221,0 @@ class C3Setting:
  210. -class Test_c3_ro(Test_ro):
  211. -
  212. - def setUp(self):
  213. - Test_ro.setUp(self)
  214. - from zope.testing.loggingsupport import InstalledHandler
  215. - self.log_handler = handler = InstalledHandler('zope.interface.ro')
  216. - self.addCleanup(handler.uninstall)
  217. -
  218. - def _callFUT(self, ob, **kwargs):
  219. - from zope.interface.ro import ro
  220. - return ro(ob, **kwargs)
  221. -
  222. - def _make_complex_diamond(self, base):
  223. - # https://github.com/zopefoundation/zope.interface/issues/21
  224. -
  225. - class F(base):
  226. - pass
  227. -
  228. - class E(base):
  229. - pass
  230. -
  231. - class D(base):
  232. - pass
  233. -
  234. - class C(D, F):
  235. - pass
  236. -
  237. - class B(D, E):
  238. - pass
  239. -
  240. - class A(B, C):
  241. - pass
  242. -
  243. - if hasattr(A, 'mro'):
  244. - self.assertEqual(A.mro(), self._callFUT(A))
  245. -
  246. - return A
  247. -
  248. - def test_complex_diamond_object(self):
  249. - self._make_complex_diamond(object)
  250. -
  251. - def test_complex_diamond_interface(self):
  252. - from zope.interface import Interface
  253. -
  254. - IA = self._make_complex_diamond(Interface)
  255. -
  256. - self.assertEqual(
  257. - [x.__name__ for x in IA.__iro__],
  258. - ['A', 'B', 'C', 'D', 'E', 'F', 'Interface']
  259. - )
  260. -
  261. - def test_complex_diamond_use_legacy_argument(self):
  262. - from zope.interface import Interface
  263. -
  264. - A = self._make_complex_diamond(Interface)
  265. - legacy_A_iro = self._callFUT(A, use_legacy_ro=True)
  266. - self.assertNotEqual(A.__iro__, legacy_A_iro)
  267. -
  268. - # And logging happened as a side-effect.
  269. - self._check_handler_complex_diamond()
  270. -
  271. - def test_complex_diamond_compare_legacy_argument(self):
  272. - from zope.interface import Interface
  273. -
  274. - A = self._make_complex_diamond(Interface)
  275. - computed_A_iro = self._callFUT(A, log_changed_ro=True)
  276. - # It matches, of course, but we did log a warning.
  277. - self.assertEqual(tuple(computed_A_iro), A.__iro__)
  278. - self._check_handler_complex_diamond()
  279. -
  280. - def _check_handler_complex_diamond(self):
  281. - handler = self.log_handler
  282. - self.assertEqual(1, len(handler.records))
  283. - record = handler.records[0]
  284. -
  285. - expected = """\
  286. -Object <InterfaceClass {name}> has different legacy and C3 MROs:
  287. - Legacy RO (len=7) C3 RO (len=7; inconsistent=no)
  288. - ==================================================================
  289. - zope.interface.tests.test_ro.A zope.interface.tests.test_ro.A
  290. - zope.interface.tests.test_ro.B zope.interface.tests.test_ro.B
  291. - - zope.interface.tests.test_ro.E
  292. - zope.interface.tests.test_ro.C zope.interface.tests.test_ro.C
  293. - zope.interface.tests.test_ro.D zope.interface.tests.test_ro.D
  294. - + zope.interface.tests.test_ro.E
  295. - zope.interface.tests.test_ro.F zope.interface.tests.test_ro.F
  296. - zope.interface.Interface zope.interface.Interface""".format(
  297. - name="zope.interface.tests.test_ro.A"
  298. - )
  299. -
  300. - self.assertEqual(
  301. - '\n'.join(ln.rstrip() for ln in record.getMessage().splitlines()),
  302. - expected,
  303. - )
  304. -
  305. - def test_ExtendedPathIndex_implement_thing_implementedby_super(self):
  306. - # See
  307. - # https://github.com/zopefoundation/zope.interface/pull/182#issuecomment-598754056
  308. - from zope.interface import ro
  309. -
  310. - # pylint:disable=inherit-non-class
  311. - class _Based:
  312. - __bases__ = ()
  313. -
  314. - def __init__(self, name, bases=(), attrs=None):
  315. - self.__name__ = name
  316. - self.__bases__ = bases
  317. -
  318. - def __repr__(self):
  319. - return self.__name__
  320. -
  321. - Interface = _Based('Interface', (), {})
  322. -
  323. - class IPluggableIndex(Interface):
  324. - pass
  325. -
  326. - class ILimitedResultIndex(IPluggableIndex):
  327. - pass
  328. -
  329. - class IQueryIndex(IPluggableIndex):
  330. - pass
  331. -
  332. - class IPathIndex(Interface):
  333. - pass
  334. -
  335. - # A parent class who implements two distinct interfaces whose
  336. - # only common ancestor is Interface. An easy case.
  337. - # @implementer(IPathIndex, IQueryIndex)
  338. - # class PathIndex(object):
  339. - # pass
  340. - obj = _Based('object')
  341. - PathIndex = _Based('PathIndex', (IPathIndex, IQueryIndex, obj))
  342. -
  343. - # Child class that tries to put an interface the parent declares
  344. - # later ahead of the parent.
  345. - # @implementer(ILimitedResultIndex, IQueryIndex)
  346. - # class ExtendedPathIndex(PathIndex):
  347. - # pass
  348. - ExtendedPathIndex = _Based(
  349. - 'ExtendedPathIndex',
  350. - (ILimitedResultIndex, IQueryIndex, PathIndex)
  351. - )
  352. -
  353. - # We were able to resolve it, and in exactly the same way as
  354. - # the legacy RO did, even though it is inconsistent.
  355. - result = self._callFUT(
  356. - ExtendedPathIndex, log_changed_ro=True, strict=False
  357. - )
  358. - self.assertEqual(result, [
  359. - ExtendedPathIndex,
  360. - ILimitedResultIndex,
  361. - PathIndex,
  362. - IPathIndex,
  363. - IQueryIndex,
  364. - IPluggableIndex,
  365. - Interface,
  366. - obj])
  367. -
  368. - record, = self.log_handler.records
  369. - self.assertIn('used the legacy', record.getMessage())
  370. -
  371. - with self.assertRaises(ro.InconsistentResolutionOrderError):
  372. - self._callFUT(ExtendedPathIndex, strict=True)
  373. -
  374. - def test_OSError_IOError(self):
  375. - from zope.interface import providedBy
  376. - from zope.interface.common import interfaces
  377. -
  378. - self.assertEqual(
  379. - list(providedBy(OSError()).flattened()),
  380. - [
  381. - interfaces.IOSError,
  382. - interfaces.IIOError,
  383. - interfaces.IEnvironmentError,
  384. - interfaces.IStandardError,
  385. - interfaces.IException,
  386. - interfaces.Interface,
  387. - ])
  388. -
  389. - def test_non_orderable(self):
  390. - import warnings
  391. -
  392. - from zope.interface import ro
  393. - try:
  394. - # If we've already warned, we must reset that state.
  395. - del ro.__warningregistry__
  396. - except AttributeError:
  397. - pass
  398. -
  399. - with warnings.catch_warnings():
  400. - warnings.simplefilter('error')
  401. - with C3Setting(
  402. - ro.C3.WARN_BAD_IRO, True
  403. - ), C3Setting(
  404. - ro.C3.STRICT_IRO, False
  405. - ):
  406. - with self.assertRaises(ro.InconsistentResolutionOrderWarning):
  407. - super().test_non_orderable()
  408. -
  409. - IOErr, _ = self._make_IOErr()
  410. - with self.assertRaises(ro.InconsistentResolutionOrderError):
  411. - self._callFUT(IOErr, strict=True)
  412. -
  413. - with C3Setting(
  414. - ro.C3.TRACK_BAD_IRO, True
  415. - ), C3Setting(
  416. - ro.C3.STRICT_IRO, False
  417. - ):
  418. - with warnings.catch_warnings():
  419. - warnings.simplefilter('ignore')
  420. - self._callFUT(IOErr)
  421. - self.assertIn(IOErr, ro.C3.BAD_IROS)
  422. -
  423. - iro = self._callFUT(IOErr, strict=False)
  424. - legacy_iro = self._callFUT(IOErr, use_legacy_ro=True, strict=False)
  425. - self.assertEqual(iro, legacy_iro)
  426. -
  427. -