zope.pytestlayer 8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. zope/pytestlayer/__init__.py +0 -0
  2. zope/pytestlayer/_compat.py +18 -0
  3. zope/pytestlayer/doctest.py +31 -0
  4. zope/pytestlayer/fixture.py +234 -0
  5. zope/pytestlayer/layered.py +100 -0
  6. zope/pytestlayer/plugin.py +122 -0
  7. zope/pytestlayer/testing.py +6 -0
  8. zope/pytestlayer/tests/__init__.py +0 -0
  9. zope/pytestlayer/tests/conftest.py +3 -0
  10. zope/pytestlayer/tests/fixture/bad_layer/__init__.py +0 -0
  11. zope/pytestlayer/tests/fixture/bad_layer/conftest.py +1 -0
  12. zope/pytestlayer/tests/fixture/bad_layer/test_core.py +13 -0
  13. zope/pytestlayer/tests/fixture/custom_fixture_name/__init__.py +0 -0
  14. zope/pytestlayer/tests/fixture/custom_fixture_name/conftest.py +12 -0
  15. zope/pytestlayer/tests/fixture/custom_fixture_name/test_core.py +38 -0
  16. zope/pytestlayer/tests/fixture/keep_layer_across_test_classes/__init__.py +0 -0
  17. zope/pytestlayer/tests/fixture/keep_layer_across_test_classes/conftest.py +1 -0
  18. zope/pytestlayer/tests/fixture/keep_layer_across_test_classes/test_core.py +101 -0
  19. zope/pytestlayer/tests/fixture/layers_with_same_name/__init__.py +0 -0
  20. zope/pytestlayer/tests/fixture/layers_with_same_name/conftest.py +1 -0
  21. zope/pytestlayer/tests/fixture/layers_with_same_name/test_core.py +40 -0
  22. zope/pytestlayer/tests/fixture/no_setup_or_teardown/__init__.py +0 -0
  23. zope/pytestlayer/tests/fixture/no_setup_or_teardown/conftest.py +1 -0
  24. zope/pytestlayer/tests/fixture/no_setup_or_teardown/test_core.py +14 -0
  25. zope/pytestlayer/tests/fixture/order_by_layer/__init__.py +0 -0
  26. zope/pytestlayer/tests/fixture/order_by_layer/conftest.py +1 -0
  27. zope/pytestlayer/tests/fixture/order_by_layer/test_core.py +112 -0
  28. zope/pytestlayer/tests/fixture/order_with_layered_suite/__init__.py +0 -0
  29. zope/pytestlayer/tests/fixture/order_with_layered_suite/conftest.py +1 -0
  30. zope/pytestlayer/tests/fixture/order_with_layered_suite/foo.txt +14 -0
  31. zope/pytestlayer/tests/fixture/order_with_layered_suite/foobar.txt +14 -0
  32. zope/pytestlayer/tests/fixture/order_with_layered_suite/test_core.py +139 -0
  33. zope/pytestlayer/tests/fixture/session_fixture/__init__.py +0 -0
  34. zope/pytestlayer/tests/fixture/session_fixture/conftest.py +13 -0
  35. zope/pytestlayer/tests/fixture/session_fixture/test_core.py +37 -0
  36. zope/pytestlayer/tests/fixture/shared_with_layered_suite/__init__.py +0 -0
  37. zope/pytestlayer/tests/fixture/shared_with_layered_suite/conftest.py +1 -0
  38. zope/pytestlayer/tests/fixture/shared_with_layered_suite/mydoctest.txt +10 -0
  39. zope/pytestlayer/tests/fixture/shared_with_layered_suite/test_core.py +53 -0
  40. zope/pytestlayer/tests/fixture/single_layer/__init__.py +0 -0
  41. zope/pytestlayer/tests/fixture/single_layer/conftest.py +1 -0
  42. zope/pytestlayer/tests/fixture/single_layer/test_core.py +33 -0
  43. zope/pytestlayer/tests/fixture/single_layer_in_two_modules/__init__.py +0 -0
  44. zope/pytestlayer/tests/fixture/single_layer_in_two_modules/conftest.py +1 -0
  45. zope/pytestlayer/tests/fixture/single_layer_in_two_modules/test_core.py +33 -0
  46. zope/pytestlayer/tests/fixture/single_layer_in_two_modules/test_second_module.py +12 -0
  47. zope/pytestlayer/tests/fixture/single_layer_with_unattached_base_layer/__init__.py +0 -0
  48. zope/pytestlayer/tests/fixture/single_layer_with_unattached_base_layer/conftest.py +1 -0
  49. zope/pytestlayer/tests/fixture/single_layer_with_unattached_base_layer/test_core.py +54 -0
  50. zope/pytestlayer/tests/fixture/single_layered_suite/__init__.py +0 -0
  51. zope/pytestlayer/tests/fixture/single_layered_suite/conftest.py +1 -0
  52. zope/pytestlayer/tests/fixture/single_layered_suite/doctest.txt +10 -0
  53. zope/pytestlayer/tests/fixture/single_layered_suite/test_core.py +44 -0
  54. zope/pytestlayer/tests/fixture/two_dependent_layered_suites/__init__.py +0 -0
  55. zope/pytestlayer/tests/fixture/two_dependent_layered_suites/bar.txt +14 -0
  56. zope/pytestlayer/tests/fixture/two_dependent_layered_suites/conftest.py +1 -0
  57. zope/pytestlayer/tests/fixture/two_dependent_layered_suites/foo.txt +14 -0
  58. zope/pytestlayer/tests/fixture/two_dependent_layered_suites/test_core.py +72 -0
  59. zope/pytestlayer/tests/fixture/two_dependent_layers/__init__.py +0 -0
  60. zope/pytestlayer/tests/fixture/two_dependent_layers/conftest.py +1 -0
  61. zope/pytestlayer/tests/fixture/two_dependent_layers/test_core.py +67 -0
  62. zope/pytestlayer/tests/fixture/two_independent_layers/__init__.py +0 -0
  63. zope/pytestlayer/tests/fixture/two_independent_layers/conftest.py +1 -0
  64. zope/pytestlayer/tests/fixture/two_independent_layers/test_core.py +67 -0
  65. zope/pytestlayer/tests/fixture/with_and_without_layer/__init__.py +0 -0
  66. zope/pytestlayer/tests/fixture/with_and_without_layer/conftest.py +1 -0
  67. zope/pytestlayer/tests/fixture/with_and_without_layer/test_core.py +39 -0
  68. zope/pytestlayer/tests/test_doctest.py +16 -0
  69. zope/pytestlayer/tests/test_fixture.py +17 -0
  70. zope/pytestlayer/tests/test_integration.py +524 -0
  71. zope/pytestlayer/tests/test_layer.py +13 -0
  72. zope.pytestlayer-8.2-py3.11-nspkg.pth +1 -0
  73. zope.pytestlayer-8.2.dist-info/LICENSE.txt +43 -0
  74. zope.pytestlayer-8.2.dist-info/METADATA +318 -0
  75. zope.pytestlayer-8.2.dist-info/RECORD +79 -0
  76. zope.pytestlayer-8.2.dist-info/WHEEL +5 -0
  77. zope.pytestlayer-8.2.dist-info/entry_points.txt +2 -0
  78. zope.pytestlayer-8.2.dist-info/namespace_packages.txt +1 -0
  79. zope.pytestlayer-8.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,54 @@
1
+ import unittest
2
+
3
+ from zope.pytestlayer.testing import log_to_terminal
4
+
5
+
6
+ class BarLayer(object):
7
+
8
+ @classmethod
9
+ def setUp(cls):
10
+ cls.layer_bar = 'layer bar'
11
+
12
+ @classmethod
13
+ def tearDown(cls):
14
+ del cls.layer_bar
15
+
16
+ @classmethod
17
+ def testSetUp(cls):
18
+ log_to_terminal(cls.pytest_request, 'testSetUp bar')
19
+ cls.test_bar = 'test bar'
20
+
21
+ @classmethod
22
+ def testTearDown(cls):
23
+ log_to_terminal(cls.pytest_request, 'testTearDown bar')
24
+ del cls.test_bar
25
+
26
+
27
+ class FooLayer(BarLayer):
28
+
29
+ @classmethod
30
+ def setUp(cls):
31
+ cls.layer_foo = 'layer foo'
32
+
33
+ @classmethod
34
+ def tearDown(cls):
35
+ del cls.layer_foo
36
+
37
+ @classmethod
38
+ def testSetUp(cls):
39
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
40
+ cls.test_foo = 'test foo'
41
+
42
+ @classmethod
43
+ def testTearDown(cls):
44
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
45
+ del cls.test_foo
46
+
47
+
48
+ class FooTest(unittest.TestCase):
49
+
50
+ layer = FooLayer
51
+
52
+ def test_dummy(self):
53
+ self.assertEqual('layer foo', self.layer.layer_foo)
54
+ self.assertEqual('test foo', self.layer.test_foo)
@@ -0,0 +1 @@
1
+ pytest_plugins = ('zopelayer', )
@@ -0,0 +1,10 @@
1
+ Test layered suite
2
+ ------------------
3
+
4
+ >>> layer
5
+ <class 'single_layered_suite.test_core.FooLayer'>
6
+
7
+ >>> layer.layer_foo
8
+ 'layer foo'
9
+ >>> layer.test_foo
10
+ 'test foo'
@@ -0,0 +1,44 @@
1
+ import doctest
2
+ import unittest
3
+
4
+ from plone.testing import layered
5
+
6
+ from zope.pytestlayer.testing import log_to_terminal
7
+
8
+
9
+ class FooLayer(object):
10
+
11
+ @classmethod
12
+ def setUp(cls):
13
+ cls.layer_foo = 'layer foo'
14
+
15
+ @classmethod
16
+ def tearDown(cls):
17
+ del cls.layer_foo
18
+
19
+ @classmethod
20
+ def testSetUp(cls):
21
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
22
+ cls.test_foo = 'test foo'
23
+
24
+ @classmethod
25
+ def testTearDown(cls):
26
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
27
+ del cls.test_foo
28
+
29
+
30
+ def test_suite():
31
+ suite = unittest.TestSuite()
32
+
33
+ OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
34
+
35
+ suite.addTests([
36
+ layered(
37
+ doctest.DocFileSuite(
38
+ 'doctest.txt',
39
+ optionflags=OPTIONFLAGS,
40
+ ),
41
+ layer=FooLayer,
42
+ ),
43
+ ])
44
+ return suite
@@ -0,0 +1,14 @@
1
+ Test layered suite
2
+ ------------------
3
+
4
+ >>> layer
5
+ <class 'two_dependent_layered_suites.test_core.BarLayer'>
6
+
7
+ >>> layer.layer_foo
8
+ 'layer foo'
9
+ >>> layer.test_foo
10
+ 'test foo'
11
+ >>> layer.layer_bar
12
+ 'layer bar'
13
+ >>> layer.test_bar
14
+ 'test bar'
@@ -0,0 +1 @@
1
+ pytest_plugins = ('zopelayer', )
@@ -0,0 +1,14 @@
1
+ Test layered suite
2
+ ------------------
3
+
4
+ >>> layer
5
+ <class 'two_dependent_layered_suites.test_core.FooLayer'>
6
+
7
+ >>> layer.layer_foo
8
+ 'layer foo'
9
+ >>> layer.test_foo
10
+ 'test foo'
11
+ >>> hasattr(layer, 'layer_bar')
12
+ False
13
+ >>> hasattr(layer, 'test_bar')
14
+ False
@@ -0,0 +1,72 @@
1
+ import doctest
2
+ import unittest
3
+
4
+ from plone.testing import layered
5
+
6
+ from zope.pytestlayer.testing import log_to_terminal
7
+
8
+
9
+ class FooLayer(object):
10
+
11
+ @classmethod
12
+ def setUp(cls):
13
+ cls.layer_foo = 'layer foo'
14
+
15
+ @classmethod
16
+ def tearDown(cls):
17
+ del cls.layer_foo
18
+
19
+ @classmethod
20
+ def testSetUp(cls):
21
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
22
+ cls.test_foo = 'test foo'
23
+
24
+ @classmethod
25
+ def testTearDown(cls):
26
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
27
+ del cls.test_foo
28
+
29
+
30
+ class BarLayer(FooLayer):
31
+
32
+ @classmethod
33
+ def setUp(cls):
34
+ cls.layer_bar = 'layer bar'
35
+
36
+ @classmethod
37
+ def tearDown(cls):
38
+ del cls.layer_bar
39
+
40
+ @classmethod
41
+ def testSetUp(cls):
42
+ log_to_terminal(cls.pytest_request, 'testSetUp bar')
43
+ cls.test_bar = 'test bar'
44
+
45
+ @classmethod
46
+ def testTearDown(cls):
47
+ log_to_terminal(cls.pytest_request, 'testTearDown bar')
48
+ del cls.test_bar
49
+
50
+
51
+ def test_suite():
52
+ suite = unittest.TestSuite()
53
+
54
+ OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
55
+
56
+ suite.addTests([
57
+ layered(
58
+ doctest.DocFileSuite(
59
+ 'foo.txt',
60
+ optionflags=OPTIONFLAGS,
61
+ ),
62
+ layer=FooLayer,
63
+ ),
64
+ layered(
65
+ doctest.DocFileSuite(
66
+ 'bar.txt',
67
+ optionflags=OPTIONFLAGS,
68
+ ),
69
+ layer=BarLayer,
70
+ ),
71
+ ])
72
+ return suite
@@ -0,0 +1 @@
1
+ pytest_plugins = ('zopelayer', )
@@ -0,0 +1,67 @@
1
+ import unittest
2
+
3
+ from zope.pytestlayer.testing import log_to_terminal
4
+
5
+
6
+ class FooLayer(object):
7
+
8
+ @classmethod
9
+ def setUp(cls):
10
+ cls.layer_foo = 'layer foo'
11
+
12
+ @classmethod
13
+ def tearDown(cls):
14
+ del cls.layer_foo
15
+
16
+ @classmethod
17
+ def testSetUp(cls):
18
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
19
+ cls.test_foo = 'test foo'
20
+
21
+ @classmethod
22
+ def testTearDown(cls):
23
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
24
+ del cls.test_foo
25
+
26
+
27
+ class BarLayer(FooLayer):
28
+
29
+ @classmethod
30
+ def setUp(cls):
31
+ cls.layer_bar = 'layer bar'
32
+
33
+ @classmethod
34
+ def tearDown(cls):
35
+ del cls.layer_bar
36
+
37
+ @classmethod
38
+ def testSetUp(cls):
39
+ log_to_terminal(cls.pytest_request, 'testSetUp bar')
40
+ cls.test_bar = 'test bar'
41
+
42
+ @classmethod
43
+ def testTearDown(cls):
44
+ log_to_terminal(cls.pytest_request, 'testTearDown bar')
45
+ del cls.test_bar
46
+
47
+
48
+ class FooTest(unittest.TestCase):
49
+
50
+ layer = FooLayer
51
+
52
+ def test_dummy(self):
53
+ self.assertEqual('layer foo', self.layer.layer_foo)
54
+ self.assertEqual('test foo', self.layer.test_foo)
55
+ self.assertFalse(hasattr(self.layer, 'layer_bar'))
56
+ self.assertFalse(hasattr(self.layer, 'test_bar'))
57
+
58
+
59
+ class BarTest(unittest.TestCase):
60
+
61
+ layer = BarLayer
62
+
63
+ def test_dummy(self):
64
+ self.assertEqual('layer foo', self.layer.layer_foo)
65
+ self.assertEqual('test foo', self.layer.test_foo)
66
+ self.assertEqual('layer bar', self.layer.layer_bar)
67
+ self.assertEqual('test bar', self.layer.test_bar)
@@ -0,0 +1 @@
1
+ pytest_plugins = ('zopelayer', )
@@ -0,0 +1,67 @@
1
+ import unittest
2
+
3
+ from zope.pytestlayer.testing import log_to_terminal
4
+
5
+
6
+ class FooLayer(object):
7
+
8
+ @classmethod
9
+ def setUp(cls):
10
+ cls.layer_foo = 'layer foo'
11
+
12
+ @classmethod
13
+ def tearDown(cls):
14
+ del cls.layer_foo
15
+
16
+ @classmethod
17
+ def testSetUp(cls):
18
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
19
+ cls.test_foo = 'test foo'
20
+
21
+ @classmethod
22
+ def testTearDown(cls):
23
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
24
+ del cls.test_foo
25
+
26
+
27
+ class BarLayer(object):
28
+
29
+ @classmethod
30
+ def setUp(cls):
31
+ cls.layer_bar = 'layer bar'
32
+
33
+ @classmethod
34
+ def tearDown(cls):
35
+ del cls.layer_bar
36
+
37
+ @classmethod
38
+ def testSetUp(cls):
39
+ log_to_terminal(cls.pytest_request, 'testSetUp bar')
40
+ cls.test_bar = 'test bar'
41
+
42
+ @classmethod
43
+ def testTearDown(cls):
44
+ log_to_terminal(cls.pytest_request, 'testTearDown bar')
45
+ del cls.test_bar
46
+
47
+
48
+ class FooTest(unittest.TestCase):
49
+
50
+ layer = FooLayer
51
+
52
+ def test_dummy(self):
53
+ self.assertEqual('layer foo', self.layer.layer_foo)
54
+ self.assertEqual('test foo', self.layer.test_foo)
55
+ self.assertFalse(hasattr(self.layer, 'layer_bar'))
56
+ self.assertFalse(hasattr(self.layer, 'test_bar'))
57
+
58
+
59
+ class BarTest(unittest.TestCase):
60
+
61
+ layer = BarLayer
62
+
63
+ def test_dummy(self):
64
+ self.assertFalse(hasattr(self.layer, 'layer_foo'))
65
+ self.assertFalse(hasattr(self.layer, 'test_foo'))
66
+ self.assertEqual('layer bar', self.layer.layer_bar)
67
+ self.assertEqual('test bar', self.layer.test_bar)
@@ -0,0 +1 @@
1
+ pytest_plugins = ('zopelayer', )
@@ -0,0 +1,39 @@
1
+ import unittest
2
+
3
+ from zope.pytestlayer.testing import log_to_terminal
4
+
5
+
6
+ class FooLayer(object):
7
+
8
+ @classmethod
9
+ def setUp(cls):
10
+ cls.layer_foo = 'layer foo'
11
+
12
+ @classmethod
13
+ def tearDown(cls):
14
+ del cls.layer_foo
15
+
16
+ @classmethod
17
+ def testSetUp(cls):
18
+ log_to_terminal(cls.pytest_request, 'testSetUp foo')
19
+ cls.test_foo = 'test foo'
20
+
21
+ @classmethod
22
+ def testTearDown(cls):
23
+ log_to_terminal(cls.pytest_request, 'testTearDown foo')
24
+ del cls.test_foo
25
+
26
+
27
+ class FooTest(unittest.TestCase):
28
+
29
+ layer = FooLayer
30
+
31
+ def test_dummy(self):
32
+ self.assertEqual('layer foo', self.layer.layer_foo)
33
+ self.assertEqual('test foo', self.layer.test_foo)
34
+
35
+
36
+ class UnitTest(unittest.TestCase):
37
+
38
+ def test_dummy(self):
39
+ self.assertFalse(hasattr(self, 'layer'))
@@ -0,0 +1,16 @@
1
+ from zope.pytestlayer.doctest import DocTestSuite
2
+
3
+
4
+ class Dummy:
5
+ """This class has a doctest.
6
+
7
+ It tests the workaround for
8
+ https://github.com/zope/zope.pytestlayer/issues/4
9
+
10
+ >>> print('foobar.')
11
+ foobar.
12
+ """
13
+
14
+
15
+ def test_suite():
16
+ return DocTestSuite('zope.pytestlayer.tests.test_doctest')
@@ -0,0 +1,17 @@
1
+ from .. import fixture
2
+
3
+
4
+ class Layer(object):
5
+ pass
6
+
7
+
8
+ def test_create_accepts_dotted_names_of_layers():
9
+ fixtures = sorted(fixture.create(
10
+ 'zope.pytestlayer.tests.test_fixture.Layer').keys())
11
+ assert 3 == len(fixtures)
12
+ assert fixtures[0].startswith(
13
+ 'zope_layer_class_zope_pytestlayer_tests_test_fixture_Layer_')
14
+ assert fixtures[1].startswith(
15
+ 'zope_layer_function_zope_pytestlayer_tests_test_fixture_Layer_')
16
+ assert fixtures[2].startswith(
17
+ 'zope_layer_session_zope_pytestlayer_tests_test_fixture_Layer_')