01-fix-tests.patch 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. --- contrib/python/zope.interface/py2/zope/interface/common/tests/basemapping.py (index)
  2. +++ contrib/python/zope.interface/py2/zope/interface/common/tests/basemapping.py (working tree)
  3. @@ -15,7 +15,7 @@
  4. """
  5. from operator import __getitem__
  6. -def testIReadMapping(self, inst, state, absent):
  7. +def _testIReadMapping(self, inst, state, absent):
  8. for key in state:
  9. self.assertEqual(inst[key], state[key])
  10. self.assertEqual(inst.get(key, None), state[key])
  11. @@ -28,39 +28,39 @@ def testIReadMapping(self, inst, state, absent):
  12. self.assertRaises(KeyError, __getitem__, inst, key)
  13. -def test_keys(self, inst, state):
  14. +def _test_keys(self, inst, state):
  15. # Return the keys of the mapping object
  16. inst_keys = list(inst.keys()); inst_keys.sort()
  17. state_keys = list(state.keys()) ; state_keys.sort()
  18. self.assertEqual(inst_keys, state_keys)
  19. -def test_iter(self, inst, state):
  20. +def _test_iter(self, inst, state):
  21. # Return the keys of the mapping object
  22. inst_keys = list(inst); inst_keys.sort()
  23. state_keys = list(state.keys()) ; state_keys.sort()
  24. self.assertEqual(inst_keys, state_keys)
  25. -def test_values(self, inst, state):
  26. +def _test_values(self, inst, state):
  27. # Return the values of the mapping object
  28. inst_values = list(inst.values()); inst_values.sort()
  29. state_values = list(state.values()) ; state_values.sort()
  30. self.assertEqual(inst_values, state_values)
  31. -def test_items(self, inst, state):
  32. +def _test_items(self, inst, state):
  33. # Return the items of the mapping object
  34. inst_items = list(inst.items()); inst_items.sort()
  35. state_items = list(state.items()) ; state_items.sort()
  36. self.assertEqual(inst_items, state_items)
  37. -def test___len__(self, inst, state):
  38. +def _test___len__(self, inst, state):
  39. # Return the number of items
  40. self.assertEqual(len(inst), len(state))
  41. -def testIEnumerableMapping(self, inst, state):
  42. - test_keys(self, inst, state)
  43. - test_items(self, inst, state)
  44. - test_values(self, inst, state)
  45. - test___len__(self, inst, state)
  46. +def _testIEnumerableMapping(self, inst, state):
  47. + _test_keys(self, inst, state)
  48. + _test_items(self, inst, state)
  49. + _test_values(self, inst, state)
  50. + _test___len__(self, inst, state)
  51. class BaseTestIReadMapping(object):
  52. @@ -68,7 +68,7 @@ class BaseTestIReadMapping(object):
  53. inst = self._IReadMapping__sample()
  54. state = self._IReadMapping__stateDict()
  55. absent = self._IReadMapping__absentKeys()
  56. - testIReadMapping(self, inst, state, absent)
  57. + _testIReadMapping(self, inst, state, absent)
  58. class BaseTestIEnumerableMapping(BaseTestIReadMapping):
  59. @@ -77,25 +77,25 @@ class BaseTestIEnumerableMapping(BaseTestIReadMapping):
  60. # Return the keys of the mapping object
  61. inst = self._IEnumerableMapping__sample()
  62. state = self._IEnumerableMapping__stateDict()
  63. - test_keys(self, inst, state)
  64. + _test_keys(self, inst, state)
  65. def test_values(self):
  66. # Return the values of the mapping object
  67. inst = self._IEnumerableMapping__sample()
  68. state = self._IEnumerableMapping__stateDict()
  69. - test_values(self, inst, state)
  70. + _test_values(self, inst, state)
  71. def test_items(self):
  72. # Return the items of the mapping object
  73. inst = self._IEnumerableMapping__sample()
  74. state = self._IEnumerableMapping__stateDict()
  75. - test_items(self, inst, state)
  76. + _test_items(self, inst, state)
  77. def test___len__(self):
  78. # Return the number of items
  79. inst = self._IEnumerableMapping__sample()
  80. state = self._IEnumerableMapping__stateDict()
  81. - test___len__(self, inst, state)
  82. + _test___len__(self, inst, state)
  83. def _IReadMapping__stateDict(self):
  84. return self._IEnumerableMapping__stateDict()
  85. --- contrib/python/zope.interface/py2/zope/interface/tests/__init__.py (index)
  86. +++ contrib/python/zope.interface/py2/zope/interface/tests/__init__.py (working tree)
  87. @@ -23,7 +23,7 @@ class OptimizationTestMixin(object):
  88. # get the Python object from that.
  89. raise NotImplementedError
  90. - def test_optimizations(self):
  91. + def _test_optimizations(self):
  92. used = self._getTargetClass()
  93. fallback = self._getFallbackClass()
  94. --- contrib/python/zope.interface/py2/zope/interface/tests/dummy.py (index)
  95. +++ contrib/python/zope.interface/py2/zope/interface/tests/dummy.py (working tree)
  96. @@ -14,7 +14,7 @@
  97. """ Dummy Module
  98. """
  99. from zope.interface import moduleProvides
  100. -from zope.interface.tests.idummy import IDummyModule
  101. +from .idummy import IDummyModule
  102. moduleProvides(IDummyModule)
  103. --- contrib/python/zope.interface/py2/zope/interface/tests/test_adapter.py (index)
  104. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_adapter.py (working tree)
  105. @@ -15,7 +15,7 @@
  106. """
  107. import unittest
  108. -from zope.interface.tests import OptimizationTestMixin
  109. +from __tests__.tests import OptimizationTestMixin
  110. # pylint:disable=inherit-non-class,protected-access,too-many-lines
  111. # pylint:disable=attribute-defined-outside-init,blacklisted-name
  112. @@ -1640,7 +1640,7 @@ class AdapterLookupBaseTests(unittest.TestCase):
  113. # but after https://github.com/zopefoundation/zope.interface/issues/200
  114. # they get propagated.
  115. from zope.interface.interface import InterfaceClass
  116. - from zope.interface.tests import MissingSomeAttrs
  117. + from __tests__.tests import MissingSomeAttrs
  118. IFoo = InterfaceClass('IFoo')
  119. registry = self._makeRegistry()
  120. --- contrib/python/zope.interface/py2/zope/interface/tests/test_advice.py (index)
  121. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_advice.py (working tree)
  122. @@ -35,7 +35,7 @@ from zope.interface._compat import _skip_under_py3k
  123. class FrameInfoTest(unittest.TestCase):
  124. def test_w_module(self):
  125. - from zope.interface.tests import advisory_testing
  126. + from . import advisory_testing
  127. (kind, module,
  128. f_locals, f_globals) = advisory_testing.moduleLevelFrameInfo
  129. self.assertEqual(kind, "module")
  130. @@ -44,7 +44,7 @@ class FrameInfoTest(unittest.TestCase):
  131. @_skip_under_py3k
  132. def test_w_ClassicClass(self):
  133. - from zope.interface.tests import advisory_testing
  134. + from . import advisory_testing
  135. (kind,
  136. module,
  137. f_locals,
  138. @@ -57,7 +57,7 @@ class FrameInfoTest(unittest.TestCase):
  139. self.assertTrue(d is advisory_testing.my_globals)
  140. def test_w_NewStyleClass(self):
  141. - from zope.interface.tests import advisory_testing
  142. + from . import advisory_testing
  143. (kind,
  144. module,
  145. f_locals,
  146. @@ -95,7 +95,7 @@ class AdviceTests(unittest.TestCase):
  147. @_skip_under_py3k
  148. def test_order(self):
  149. - from zope.interface.tests.advisory_testing import ping
  150. + from .advisory_testing import ping
  151. log = []
  152. class Foo(object):
  153. ping(log, 1)
  154. @@ -111,7 +111,7 @@ class AdviceTests(unittest.TestCase):
  155. @_skip_under_py3k
  156. def test_single_explicit_meta(self):
  157. - from zope.interface.tests.advisory_testing import ping
  158. + from .advisory_testing import ping
  159. class Metaclass(type):
  160. pass
  161. @@ -126,7 +126,7 @@ class AdviceTests(unittest.TestCase):
  162. @_skip_under_py3k
  163. def test_mixed_metas(self):
  164. - from zope.interface.tests.advisory_testing import ping
  165. + from .advisory_testing import ping
  166. class Metaclass1(type):
  167. pass
  168. @@ -160,7 +160,7 @@ class AdviceTests(unittest.TestCase):
  169. @_skip_under_py3k
  170. def test_meta_no_bases(self):
  171. - from zope.interface.tests.advisory_testing import ping
  172. + from .advisory_testing import ping
  173. from types import ClassType
  174. class Thing:
  175. ping([], 1)
  176. --- contrib/python/zope.interface/py2/zope/interface/tests/test_declarations.py (index)
  177. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_declarations.py (working tree)
  178. @@ -17,9 +17,9 @@ import unittest
  179. from zope.interface._compat import _skip_under_py3k
  180. from zope.interface._compat import PYTHON3
  181. -from zope.interface.tests import OptimizationTestMixin
  182. -from zope.interface.tests import MissingSomeAttrs
  183. -from zope.interface.tests.test_interface import NameAndModuleComparisonTestsMixin
  184. +from __tests__.tests import OptimizationTestMixin
  185. +from __tests__.tests import MissingSomeAttrs
  186. +from __tests__.tests.test_interface import NameAndModuleComparisonTestsMixin
  187. # pylint:disable=inherit-non-class,too-many-lines,protected-access
  188. # pylint:disable=blacklisted-name,attribute-defined-outside-init
  189. @@ -297,7 +297,7 @@ class DeclarationTests(EmptyDeclarationTests):
  190. # the other way).
  191. from zope.interface import Interface
  192. from zope.interface.interface import InterfaceClass
  193. - from zope.interface.tests.test_ro import C3Setting
  194. + from __tests__.tests.test_ro import C3Setting
  195. from zope.interface import ro
  196. IBase = InterfaceClass('IBase')
  197. @@ -319,7 +319,7 @@ class DeclarationTests(EmptyDeclarationTests):
  198. from zope.interface import Interface
  199. from zope.interface import implementedBy
  200. from zope.interface import implementer
  201. - from zope.interface.tests.test_ro import C3Setting
  202. + from __tests__.tests.test_ro import C3Setting
  203. from zope.interface import ro
  204. class IBase(Interface):
  205. @@ -647,7 +647,7 @@ class Test_implementedByFallback(unittest.TestCase):
  206. foo.__name__ = 'foo'
  207. spec = self._callFUT(foo)
  208. self.assertEqual(spec.__name__,
  209. - 'zope.interface.tests.test_declarations.foo')
  210. + '__tests__.tests.test_declarations.foo')
  211. self.assertIs(spec.inherit, foo)
  212. self.assertIs(foo.__implemented__, spec)
  213. self.assertIs(foo.__providedBy__, objectSpecificationDescriptor) # pylint:disable=no-member
  214. @@ -659,7 +659,7 @@ class Test_implementedByFallback(unittest.TestCase):
  215. __implemented__ = None
  216. spec = self._callFUT(Foo)
  217. self.assertEqual(spec.__name__,
  218. - 'zope.interface.tests.test_declarations.Foo')
  219. + '__tests__.tests.test_declarations.Foo')
  220. self.assertIs(spec.inherit, Foo)
  221. self.assertIs(Foo.__implemented__, spec)
  222. self.assertIsInstance(Foo.__providedBy__, ClassProvides) # pylint:disable=no-member
  223. @@ -997,7 +997,7 @@ class Test_classImplements(_ImplementsTestMixin, unittest.TestCase):
  224. from zope.interface import Interface
  225. from zope.interface import implementedBy
  226. from zope.interface import ro
  227. - from zope.interface.tests.test_ro import C3Setting
  228. + from __tests__.tests.test_ro import C3Setting
  229. class Foo(object):
  230. pass
  231. @@ -1123,7 +1123,7 @@ class Test_implementer(Test_classImplements):
  232. returned = decorator(foo)
  233. self.assertTrue(returned is foo)
  234. spec = foo.__implemented__ # pylint:disable=no-member
  235. - self.assertEqual(spec.__name__, 'zope.interface.tests.test_declarations.?')
  236. + self.assertEqual(spec.__name__, '__tests__.tests.test_declarations.?')
  237. self.assertIsNone(spec.inherit,)
  238. self.assertIs(foo.__implemented__, spec) # pylint:disable=no-member
  239. @@ -1415,17 +1415,17 @@ class TestProvidesClassRepr(unittest.TestCase):
  240. def test__repr__module_provides_typical_use(self):
  241. # as created through a ``moduleProvides()`` statement
  242. # in a module body
  243. - from zope.interface.tests import dummy
  244. + from __tests__.tests import dummy
  245. provides = dummy.__provides__ # pylint:disable=no-member
  246. self.assertEqual(
  247. repr(provides),
  248. - "directlyProvides(sys.modules['zope.interface.tests.dummy'], IDummyModule)"
  249. + "directlyProvides(sys.modules['__tests__.tests.dummy'], IDummyModule)"
  250. )
  251. def test__repr__module_after_pickle(self):
  252. # It doesn't matter, these objects can't be pickled.
  253. import pickle
  254. - from zope.interface.tests import dummy
  255. + from __tests__.tests import dummy
  256. provides = dummy.__provides__ # pylint:disable=no-member
  257. for proto in range(pickle.HIGHEST_PROTOCOL + 1):
  258. with self.assertRaises(pickle.PicklingError):
  259. @@ -1433,7 +1433,7 @@ class TestProvidesClassRepr(unittest.TestCase):
  260. def test__repr__directlyProvides_module(self):
  261. import sys
  262. - from zope.interface.tests import dummy
  263. + from __tests__.tests import dummy
  264. from zope.interface.declarations import directlyProvides
  265. from zope.interface.declarations import alsoProvides
  266. from zope.interface.interface import InterfaceClass
  267. @@ -1450,7 +1450,7 @@ class TestProvidesClassRepr(unittest.TestCase):
  268. self.assertEqual(
  269. repr(provides),
  270. - "directlyProvides(sys.modules['zope.interface.tests.dummy'], IFoo)"
  271. + "directlyProvides(sys.modules['__tests__.tests.dummy'], IFoo)"
  272. )
  273. alsoProvides(dummy, IBar)
  274. @@ -1458,7 +1458,7 @@ class TestProvidesClassRepr(unittest.TestCase):
  275. self.assertEqual(
  276. repr(provides),
  277. - "directlyProvides(sys.modules['zope.interface.tests.dummy'], IFoo, IBar)"
  278. + "directlyProvides(sys.modules['__tests__.tests.dummy'], IFoo, IBar)"
  279. )
  280. # If we make this module also provide IFoo and IBar, then the repr
  281. @@ -1471,8 +1471,8 @@ class TestProvidesClassRepr(unittest.TestCase):
  282. self.assertIs(my_module.__provides__, provides)
  283. self.assertEqual(
  284. repr(provides),
  285. - "directlyProvides(('zope.interface.tests.dummy', "
  286. - "'zope.interface.tests.test_declarations'), "
  287. + "directlyProvides(('__tests__.tests.dummy', "
  288. + "'__tests__.tests.test_declarations'), "
  289. "IFoo, IBar)"
  290. )
  291. @@ -2103,7 +2103,7 @@ class Test_moduleProvides(unittest.TestCase):
  292. from zope.interface.declarations import moduleProvides
  293. from zope.interface.interface import InterfaceClass
  294. IFoo = InterfaceClass("IFoo")
  295. - globs = {'__name__': 'zope.interface.tests.foo',
  296. + globs = {'__name__': '__tests__.tests.tests.foo',
  297. 'moduleProvides': moduleProvides, 'IFoo': IFoo}
  298. locs = {}
  299. CODE = "\n".join([
  300. @@ -2118,7 +2118,7 @@ class Test_moduleProvides(unittest.TestCase):
  301. from zope.interface.declarations import moduleProvides
  302. from zope.interface.interface import InterfaceClass
  303. IFoo = InterfaceClass("IFoo")
  304. - globs = {'__name__': 'zope.interface.tests.foo',
  305. + globs = {'__name__': '__tests__.tests.tests.foo',
  306. 'moduleProvides': moduleProvides, 'IFoo': IFoo}
  307. locs = {}
  308. CODE = "\n".join([
  309. @@ -2132,7 +2132,7 @@ class Test_moduleProvides(unittest.TestCase):
  310. from zope.interface.declarations import moduleProvides
  311. from zope.interface.interface import InterfaceClass
  312. IFoo = InterfaceClass("IFoo")
  313. - globs = {'__name__': 'zope.interface.tests.foo',
  314. + globs = {'__name__': '__tests__.tests.tests.foo',
  315. 'moduleProvides': moduleProvides, 'IFoo': IFoo}
  316. CODE = "\n".join([
  317. 'moduleProvides(IFoo)',
  318. @@ -2145,7 +2145,7 @@ class Test_moduleProvides(unittest.TestCase):
  319. from zope.interface.declarations import moduleProvides
  320. from zope.interface.interface import InterfaceClass
  321. IFoo = InterfaceClass("IFoo")
  322. - globs = {'__name__': 'zope.interface.tests.foo',
  323. + globs = {'__name__': '__tests__.tests.tests.foo',
  324. 'moduleProvides': moduleProvides, 'IFoo': IFoo}
  325. CODE = "\n".join([
  326. --- contrib/python/zope.interface/py2/zope/interface/tests/test_exceptions.py (index)
  327. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_exceptions.py (working tree)
  328. @@ -36,7 +36,7 @@ class DoesNotImplementTests(unittest.TestCase):
  329. self.assertEqual(
  330. str(dni),
  331. "An object has failed to implement interface "
  332. - "zope.interface.tests.test_exceptions.IDummy: "
  333. + "__tests__.tests.test_exceptions.IDummy: "
  334. "Does not declaratively implement the interface."
  335. )
  336. @@ -45,7 +45,7 @@ class DoesNotImplementTests(unittest.TestCase):
  337. self.assertEqual(
  338. str(dni),
  339. "The object 'candidate' has failed to implement interface "
  340. - "zope.interface.tests.test_exceptions.IDummy: "
  341. + "__tests__.tests.test_exceptions.IDummy: "
  342. "Does not declaratively implement the interface."
  343. )
  344. @@ -65,7 +65,7 @@ class BrokenImplementationTests(unittest.TestCase):
  345. self.assertEqual(
  346. str(dni),
  347. 'An object has failed to implement interface '
  348. - 'zope.interface.tests.test_exceptions.IDummy: '
  349. + '__tests__.tests.test_exceptions.IDummy: '
  350. "The 'missing' attribute was not provided.")
  351. def test___str__w_candidate(self):
  352. @@ -73,7 +73,7 @@ class BrokenImplementationTests(unittest.TestCase):
  353. self.assertEqual(
  354. str(dni),
  355. 'The object \'candidate\' has failed to implement interface '
  356. - 'zope.interface.tests.test_exceptions.IDummy: '
  357. + '__tests__.tests.test_exceptions.IDummy: '
  358. "The 'missing' attribute was not provided.")
  359. @@ -161,7 +161,7 @@ class MultipleInvalidTests(unittest.TestCase):
  360. self.assertEqual(
  361. str(dni),
  362. "The object 'target' has failed to implement interface "
  363. - "zope.interface.tests.test_exceptions.IDummy:\n"
  364. + "__tests__.tests.test_exceptions.IDummy:\n"
  365. " The contract of 'aMethod' is violated because I said so\n"
  366. " Regular exception"
  367. )
  368. @@ -177,7 +177,7 @@ class MultipleInvalidTests(unittest.TestCase):
  369. dni = self._makeOne(excs)
  370. self.assertEqual(
  371. repr(dni),
  372. - "MultipleInvalid(<InterfaceClass zope.interface.tests.test_exceptions.IDummy>,"
  373. + "MultipleInvalid(<InterfaceClass __tests__.tests.test_exceptions.IDummy>,"
  374. " 'target',"
  375. " (BrokenMethodImplementation('aMethod', 'I said so'),"
  376. " Exception('Regular', 'exception')))"
  377. --- contrib/python/zope.interface/py2/zope/interface/tests/test_interface.py (index)
  378. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_interface.py (working tree)
  379. @@ -24,9 +24,9 @@
  380. import unittest
  381. from zope.interface._compat import _skip_under_py3k
  382. -from zope.interface.tests import MissingSomeAttrs
  383. -from zope.interface.tests import OptimizationTestMixin
  384. -from zope.interface.tests import CleanUp
  385. +from __tests__.tests import MissingSomeAttrs
  386. +from __tests__.tests import OptimizationTestMixin
  387. +from __tests__.tests import CleanUp
  388. _marker = object()
  389. @@ -1036,7 +1036,7 @@ class InterfaceClassTests(unittest.TestCase):
  390. iface = self._makeOne('HashMe')
  391. self.assertEqual(hash(iface),
  392. hash((('HashMe',
  393. - 'zope.interface.tests.test_interface'))))
  394. + '__tests__.tests.test_interface'))))
  395. def test___hash___missing_required_attrs(self):
  396. class Derived(self._getTargetClass()):
  397. @@ -1076,8 +1076,8 @@ class InterfaceClassTests(unittest.TestCase):
  398. def test_comparison_with_same_named_instance_in_other_module(self):
  399. - one = self._makeOne('IName', __module__='zope.interface.tests.one')
  400. - other = self._makeOne('IName', __module__='zope.interface.tests.other')
  401. + one = self._makeOne('IName', __module__='__tests__.tests.one')
  402. + other = self._makeOne('IName', __module__='__tests__.tests.other')
  403. self.assertTrue(one < other)
  404. self.assertFalse(other < one)
  405. --- contrib/python/zope.interface/py2/zope/interface/tests/test_odd_declarations.py (index)
  406. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_odd_declarations.py (working tree)
  407. @@ -18,7 +18,7 @@ classic ExtensionClass classes and instances.
  408. """
  409. import unittest
  410. -from zope.interface.tests import odd
  411. +from . import odd
  412. from zope.interface import Interface
  413. from zope.interface import implementer
  414. from zope.interface import directlyProvides
  415. --- contrib/python/zope.interface/py2/zope/interface/tests/test_ro.py (index)
  416. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_ro.py (working tree)
  417. @@ -190,197 +190,6 @@ class C3Setting(object):
  418. from zope.interface import ro
  419. setattr(ro.C3, self._setting.__name__, self._setting)
  420. -class Test_c3_ro(Test_ro):
  421. -
  422. - def setUp(self):
  423. - Test_ro.setUp(self)
  424. - from zope.testing.loggingsupport import InstalledHandler
  425. - self.log_handler = handler = InstalledHandler('zope.interface.ro')
  426. - self.addCleanup(handler.uninstall)
  427. -
  428. - def _callFUT(self, ob, **kwargs):
  429. - from zope.interface.ro import ro
  430. - return ro(ob, **kwargs)
  431. -
  432. - def test_complex_diamond(self, base=object):
  433. - # https://github.com/zopefoundation/zope.interface/issues/21
  434. - O = base
  435. - class F(O):
  436. - pass
  437. - class E(O):
  438. - pass
  439. - class D(O):
  440. - pass
  441. - class C(D, F):
  442. - pass
  443. - class B(D, E):
  444. - pass
  445. - class A(B, C):
  446. - pass
  447. -
  448. - if hasattr(A, 'mro'):
  449. - self.assertEqual(A.mro(), self._callFUT(A))
  450. -
  451. - return A
  452. -
  453. - def test_complex_diamond_interface(self):
  454. - from zope.interface import Interface
  455. -
  456. - IA = self.test_complex_diamond(Interface)
  457. -
  458. - self.assertEqual(
  459. - [x.__name__ for x in IA.__iro__],
  460. - ['A', 'B', 'C', 'D', 'E', 'F', 'Interface']
  461. - )
  462. -
  463. - def test_complex_diamond_use_legacy_argument(self):
  464. - from zope.interface import Interface
  465. -
  466. - A = self.test_complex_diamond(Interface)
  467. - legacy_A_iro = self._callFUT(A, use_legacy_ro=True)
  468. - self.assertNotEqual(A.__iro__, legacy_A_iro)
  469. -
  470. - # And logging happened as a side-effect.
  471. - self._check_handler_complex_diamond()
  472. -
  473. - def test_complex_diamond_compare_legacy_argument(self):
  474. - from zope.interface import Interface
  475. -
  476. - A = self.test_complex_diamond(Interface)
  477. - computed_A_iro = self._callFUT(A, log_changed_ro=True)
  478. - # It matches, of course, but we did log a warning.
  479. - self.assertEqual(tuple(computed_A_iro), A.__iro__)
  480. - self._check_handler_complex_diamond()
  481. -
  482. - def _check_handler_complex_diamond(self):
  483. - handler = self.log_handler
  484. - self.assertEqual(1, len(handler.records))
  485. - record = handler.records[0]
  486. -
  487. - self.assertEqual('\n'.join(l.rstrip() for l in record.getMessage().splitlines()), """\
  488. -Object <InterfaceClass zope.interface.tests.test_ro.A> has different legacy and C3 MROs:
  489. - Legacy RO (len=7) C3 RO (len=7; inconsistent=no)
  490. - ==================================================================
  491. - zope.interface.tests.test_ro.A zope.interface.tests.test_ro.A
  492. - zope.interface.tests.test_ro.B zope.interface.tests.test_ro.B
  493. - - zope.interface.tests.test_ro.E
  494. - zope.interface.tests.test_ro.C zope.interface.tests.test_ro.C
  495. - zope.interface.tests.test_ro.D zope.interface.tests.test_ro.D
  496. - + zope.interface.tests.test_ro.E
  497. - zope.interface.tests.test_ro.F zope.interface.tests.test_ro.F
  498. - zope.interface.Interface zope.interface.Interface""")
  499. -
  500. - def test_ExtendedPathIndex_implement_thing_implementedby_super(self):
  501. - # See https://github.com/zopefoundation/zope.interface/pull/182#issuecomment-598754056
  502. - from zope.interface import ro
  503. - # pylint:disable=inherit-non-class
  504. - class _Based(object):
  505. - __bases__ = ()
  506. -
  507. - def __init__(self, name, bases=(), attrs=None):
  508. - self.__name__ = name
  509. - self.__bases__ = bases
  510. -
  511. - def __repr__(self):
  512. - return self.__name__
  513. -
  514. - Interface = _Based('Interface', (), {})
  515. -
  516. - class IPluggableIndex(Interface):
  517. - pass
  518. -
  519. - class ILimitedResultIndex(IPluggableIndex):
  520. - pass
  521. -
  522. - class IQueryIndex(IPluggableIndex):
  523. - pass
  524. -
  525. - class IPathIndex(Interface):
  526. - pass
  527. -
  528. - # A parent class who implements two distinct interfaces whose
  529. - # only common ancestor is Interface. An easy case.
  530. - # @implementer(IPathIndex, IQueryIndex)
  531. - # class PathIndex(object):
  532. - # pass
  533. - obj = _Based('object')
  534. - PathIndex = _Based('PathIndex', (IPathIndex, IQueryIndex, obj))
  535. -
  536. - # Child class that tries to put an interface the parent declares
  537. - # later ahead of the parent.
  538. - # @implementer(ILimitedResultIndex, IQueryIndex)
  539. - # class ExtendedPathIndex(PathIndex):
  540. - # pass
  541. - ExtendedPathIndex = _Based('ExtendedPathIndex',
  542. - (ILimitedResultIndex, IQueryIndex, PathIndex))
  543. -
  544. - # We were able to resolve it, and in exactly the same way as
  545. - # the legacy RO did, even though it is inconsistent.
  546. - result = self._callFUT(ExtendedPathIndex, log_changed_ro=True, strict=False)
  547. - self.assertEqual(result, [
  548. - ExtendedPathIndex,
  549. - ILimitedResultIndex,
  550. - PathIndex,
  551. - IPathIndex,
  552. - IQueryIndex,
  553. - IPluggableIndex,
  554. - Interface,
  555. - obj])
  556. -
  557. - record, = self.log_handler.records
  558. - self.assertIn('used the legacy', record.getMessage())
  559. -
  560. - with self.assertRaises(ro.InconsistentResolutionOrderError):
  561. - self._callFUT(ExtendedPathIndex, strict=True)
  562. -
  563. - def test_OSError_IOError(self):
  564. - if OSError is not IOError:
  565. - # Python 2
  566. - self.skipTest("Requires Python 3 IOError == OSError")
  567. - from zope.interface.common import interfaces
  568. - from zope.interface import providedBy
  569. -
  570. - self.assertEqual(
  571. - list(providedBy(OSError()).flattened()),
  572. - [
  573. - interfaces.IOSError,
  574. - interfaces.IIOError,
  575. - interfaces.IEnvironmentError,
  576. - interfaces.IStandardError,
  577. - interfaces.IException,
  578. - interfaces.Interface,
  579. - ])
  580. -
  581. - def test_non_orderable(self):
  582. - import warnings
  583. - from zope.interface import ro
  584. - try:
  585. - # If we've already warned, we must reset that state.
  586. - del ro.__warningregistry__
  587. - except AttributeError:
  588. - pass
  589. -
  590. - with warnings.catch_warnings():
  591. - warnings.simplefilter('error')
  592. - with C3Setting(ro.C3.WARN_BAD_IRO, True), C3Setting(ro.C3.STRICT_IRO, False):
  593. - with self.assertRaises(ro.InconsistentResolutionOrderWarning):
  594. - super(Test_c3_ro, self).test_non_orderable()
  595. -
  596. - IOErr, _ = self._make_IOErr()
  597. - with self.assertRaises(ro.InconsistentResolutionOrderError):
  598. - self._callFUT(IOErr, strict=True)
  599. -
  600. - with C3Setting(ro.C3.TRACK_BAD_IRO, True), C3Setting(ro.C3.STRICT_IRO, False):
  601. - with warnings.catch_warnings():
  602. - warnings.simplefilter('ignore')
  603. - self._callFUT(IOErr)
  604. - self.assertIn(IOErr, ro.C3.BAD_IROS)
  605. -
  606. - iro = self._callFUT(IOErr, strict=False)
  607. - legacy_iro = self._callFUT(IOErr, use_legacy_ro=True, strict=False)
  608. - self.assertEqual(iro, legacy_iro)
  609. -
  610. -
  611. class TestC3(unittest.TestCase):
  612. def _makeOne(self, C, strict=False, base_mros=None):
  613. from zope.interface.ro import C3
  614. --- contrib/python/zope.interface/py2/zope/interface/tests/test_sorting.py (index)
  615. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_sorting.py (working tree)
  616. @@ -41,7 +41,7 @@ class Test(unittest.TestCase):
  617. def test_w_equal_names(self):
  618. # interfaces with equal names but different modules should sort by
  619. # module name
  620. - from zope.interface.tests.m1 import I1 as m1_I1
  621. + from .m1 import I1 as m1_I1
  622. l = [I1, m1_I1]
  623. l.sort()
  624. self.assertEqual(l, [m1_I1, I1])
  625. --- contrib/python/zope.interface/py2/zope/interface/tests/test_verify.py (index)
  626. +++ contrib/python/zope.interface/py2/zope/interface/tests/test_verify.py (working tree)
  627. @@ -614,14 +614,14 @@ class Test_verifyObject(Test_verifyClass):
  628. self._callFUT, ICurrent, Current)
  629. def test_module_hit(self):
  630. - from zope.interface.tests.idummy import IDummyModule
  631. - from zope.interface.tests import dummy
  632. + from .idummy import IDummyModule
  633. + from . import dummy
  634. self._callFUT(IDummyModule, dummy)
  635. def test_module_miss(self):
  636. from zope.interface import Interface
  637. - from zope.interface.tests import dummy
  638. + from . import dummy
  639. from zope.interface.exceptions import DoesNotImplement
  640. # same name, different object