Esempio n. 1
0
    def test_dispatch_tests_receive_events(self):
        ssn = {
            'config': self.session.config,
            'verbosity': 1,
            'startDir': support_file('scenario/tests_in_package'),
            'topLevelDir': support_file('scenario/tests_in_package'),
            'logLevel': 100,
            'pluginClasses': [discovery.DiscoveryLoader,
                              testcases.TestCaseLoader,
                              buffer.OutputBufferPlugin]

        }
        conn = Conn(['pkg1.test.test_things.SomeTests.test_ok',
                     'pkg1.test.test_things.SomeTests.test_failed'])
        procserver(ssn, conn)

        # check conn calls
        expect = [('pkg1.test.test_things.SomeTests.test_ok',
                   [('startTest', {}),
                    ('setTestOutcome', {'outcome': 'passed'}),
                    ('testOutcome', {'outcome': 'passed'}),
                    ('stopTest', {})]
                   ),
                  ('pkg1.test.test_things.SomeTests.test_failed',
                   [('startTest', {}),
                    ('setTestOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('testOutcome', {
                     'outcome': 'failed',
                     'expected': False,
                     'metadata': {'stdout': 'Hello stdout\n'}}),
                    ('stopTest', {})]
                   ),
                  ]
        for val in conn.sent:
            if val is None:
                break
            test, events = val
            exp_test, exp_events = expect.pop(0)
            self.assertEqual(test, exp_test)
            for method, event in events:
                exp_meth, exp_attr = exp_events.pop(0)
                self.assertEqual(method, exp_meth)
                for attr, val in exp_attr.items():
                    self.assertEqual(getattr(event, attr), val)
Esempio n. 2
0
 def test_gentests(self):
     conn = Conn([1, 2, 3])
     res = []
     for x in mp.gentests(conn):
         res.append(x)
     self.assertEqual(res, [1, 2, 3])
Esempio n. 3
0
    def test_dispatch_tests_receive_events(self):
        ssn = {
            "config":
            self.session.config,
            "verbosity":
            1,
            "startDir":
            support_file("scenario/tests_in_package"),
            "topLevelDir":
            support_file("scenario/tests_in_package"),
            "logLevel":
            100,
            "pluginClasses": [
                discovery.DiscoveryLoader,
                testcases.TestCaseLoader,
                buffer.OutputBufferPlugin,
            ],
        }
        conn = Conn([
            "pkg1.test.test_things.SomeTests.test_ok",
            "pkg1.test.test_things.SomeTests.test_failed",
        ])
        procserver(ssn, conn)

        # check conn calls
        expect = [
            (
                "pkg1.test.test_things.SomeTests.test_ok",
                [
                    ("startTest", {}),
                    ("setTestOutcome", {
                        "outcome": "passed"
                    }),
                    ("testOutcome", {
                        "outcome": "passed"
                    }),
                    ("stopTest", {}),
                ],
            ),
            (
                "pkg1.test.test_things.SomeTests.test_failed",
                [
                    ("startTest", {}),
                    (
                        "setTestOutcome",
                        {
                            "outcome": "failed",
                            "expected": False,
                            "metadata": {
                                "stdout":
                                """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
                            },
                        },
                    ),
                    (
                        "testOutcome",
                        {
                            "outcome": "failed",
                            "expected": False,
                            "metadata": {
                                "stdout":
                                """\
-------------------- >> begin captured stdout << ---------------------
Hello stdout

--------------------- >> end captured stdout << ----------------------"""
                            },
                        },
                    ),
                    ("stopTest", {}),
                ],
            ),
        ]
        for val in conn.sent:
            if val is None:
                break
            test, events = val
            exp_test, exp_events = expect.pop(0)
            self.assertEqual(test, exp_test)
            for method, event in events:
                exp_meth, exp_attr = exp_events.pop(0)
                self.assertEqual(method, exp_meth)
                for attr, val in exp_attr.items():
                    self.assertEqual(getattr(event, attr), val)