def test_failure_change(self, pytester: pytest.Pytester) -> None:
        modcol = pytester.getitem(
            textwrap.dedent("""
                def test_func():
                    assert 0
                """))
        control = RemoteControl(modcol.config)
        control.loop_once()
        assert control.failures
        if PYTEST_GTE_7:
            modcol_path = modcol.path  # type:ignore[attr-defined]
        else:
            modcol_path = Path(str(modcol.fspath))

        modcol_path.write_text(
            textwrap.dedent("""
                def test_func():
                    assert 1
                def test_new():
                    assert 0
                """))
        removepyc(modcol_path)
        control.loop_once()
        assert not control.failures
        control.loop_once()
        assert control.failures
        assert str(control.failures).find("test_new") != -1
    def test_looponfail_from_one_to_two_tests(
            self, pytester: pytest.Pytester) -> None:
        modcol = pytester.getmodulecol(
            textwrap.dedent("""
                def test_one():
                    assert 0
                """))
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert "test_one" in remotecontrol.failures[0]

        modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
        modcol_path.write_text(
            textwrap.dedent("""
                def test_one():
                    assert 1 # passes now
                def test_two():
                    assert 0 # new and fails
                """))
        removepyc(modcol_path)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert "test_one" not in remotecontrol.failures[0]
        assert "test_two" in remotecontrol.failures[0]
    def test_looponfail_removed_test(self, pytester: pytest.Pytester) -> None:
        modcol = pytester.getmodulecol(
            textwrap.dedent("""
                def test_one():
                    assert 0
                def test_two():
                    assert 0
                """))
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 2

        modcol.path.write_text(
            textwrap.dedent("""
                def test_xxx(): # renamed test
                    assert 0
                def test_two():
                    assert 1 # pass now
                """))
        removepyc(modcol.path)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0

        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
Example #4
0
 def test_failure_subdir_no_init(self, testdir):
     modcol = testdir.getitem("""
         def test_func():
             assert 0
     """)
     parent = modcol.fspath.dirpath().dirpath()
     parent.chdir()
     modcol.config.args = [py.path.local(x).relto(parent)
                             for x in modcol.config.args]
     control = RemoteControl(modcol.config)
     control.loop_once()
     assert control.failures
     control.loop_once()
     assert control.failures
Example #5
0
    def test_looponfail_multiple_errors(self, testdir, monkeypatch):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        orig_runsession = remotecontrol.runsession

        def runsession_dups():
            # twisted.trial test cases may report multiple errors.
            failures, reports, collection_failed = orig_runsession()
            print(failures)
            return failures * 2, reports, collection_failed

        monkeypatch.setattr(remotecontrol, "runsession", runsession_dups)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
Example #6
0
    def test_looponfail_multiple_errors(self, testdir, monkeypatch):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        orig_runsession = remotecontrol.runsession

        def runsession_dups():
            # twisted.trial test cases may report multiple errors.
            failures, reports, collection_failed = orig_runsession()
            print (failures)
            return failures * 2, reports, collection_failed

        monkeypatch.setattr(remotecontrol, 'runsession', runsession_dups)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
Example #7
0
 def test_failures_somewhere(self, testdir):
     item = testdir.getitem("def test_func():\n assert 0\n")
     control = RemoteControl(item.config)
     control.setup()
     failures = control.runsession()
     assert failures
     control.setup()
     item.fspath.write("def test_func():\n assert 1\n")
     removepyc(item.fspath)
     topdir, failures = control.runsession()[:2]
     assert not failures
 def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
     item = pytester.getitem("def test_func():\n assert 0\n")
     control = RemoteControl(item.config)
     control.setup()
     failures = control.runsession()
     assert failures
     control.setup()
     item_path = item.path if PYTEST_GTE_7 else Path(str(
         item.fspath))  # type: ignore[attr-defined]
     item_path.write_text("def test_func():\n assert 1\n")
     removepyc(item_path)
     topdir, failures = control.runsession()[:2]
     assert not failures
Example #9
0
    def test_looponfail_from_fail_to_ok(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                x = 0
                assert x == 1
            def test_two():
                assert 1
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1

        modcol.fspath.write(py.code.Source("""
            def test_one():
                assert 1
            def test_two():
                assert 1
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert not remotecontrol.failures
    def test_looponfail_from_fail_to_ok(self,
                                        pytester: pytest.Pytester) -> None:
        modcol = pytester.getmodulecol(
            textwrap.dedent("""
                def test_one():
                    x = 0
                    assert x == 1
                def test_two():
                    assert 1
                """))
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1

        modcol_path = modcol.path if PYTEST_GTE_7 else Path(modcol.fspath)
        modcol_path.write_text(
            textwrap.dedent("""
                def test_one():
                    assert 1
                def test_two():
                    assert 1
                """))
        removepyc(modcol_path)
        remotecontrol.loop_once()
        assert not remotecontrol.failures
Example #11
0
 def test_failures_somewhere(self, testdir):
     item = testdir.getitem("def test_func():\n assert 0\n")
     control = RemoteControl(item.config)
     control.setup()
     failures = control.runsession()
     assert failures
     control.setup()
     item.fspath.write("def test_func():\n assert 1\n")
     removepyc(item.fspath)
     topdir, failures = control.runsession()[:2]
     assert not failures
Example #12
0
 def test_failure_change(self, testdir):
     modcol = testdir.getitem("""
         def test_func():
             assert 0
     """)
     control = RemoteControl(modcol.config)
     control.loop_once()
     assert control.failures
     modcol.fspath.write(py.code.Source("""
         def test_func():
             assert 1
         def test_new():
             assert 0
     """))
     removepyc(modcol.fspath)
     control.loop_once()
     assert not control.failures
     control.loop_once()
     assert control.failures
     assert str(control.failures).find("test_new") != -1
Example #13
0
 def test_failure_subdir_no_init(self, testdir):
     modcol = testdir.getitem("""
         def test_func():
             assert 0
     """)
     parent = modcol.fspath.dirpath().dirpath()
     parent.chdir()
     modcol.config.args = [py.path.local(x).relto(parent)
                           for x in modcol.config.args]
     control = RemoteControl(modcol.config)
     control.loop_once()
     assert control.failures
     control.loop_once()
     assert control.failures
Example #14
0
    def test_looponfail_from_one_to_two_tests(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert 'test_one' in remotecontrol.failures[0]

        modcol.fspath.write(py.code.Source("""
            def test_one():
                assert 1 # passes now
            def test_two():
                assert 0 # new and fails
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert 'test_one' not in remotecontrol.failures[0]
        assert 'test_two' in remotecontrol.failures[0]
Example #15
0
    def test_looponfail_removed_test(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
            def test_two():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 2

        modcol.fspath.write(py.code.Source("""
            def test_xxx(): # renamed test
                assert 0
            def test_two():
                assert 1 # pass now
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0

        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
Example #16
0
 def test_failure_change(self, testdir):
     modcol = testdir.getitem("""
         def test_func():
             assert 0
     """)
     control = RemoteControl(modcol.config)
     control.loop_once()
     assert control.failures
     modcol.fspath.write(py.code.Source("""
         def test_func():
             assert 1
         def test_new():
             assert 0
     """))
     removepyc(modcol.fspath)
     control.loop_once()
     assert not control.failures
     control.loop_once()
     assert control.failures
     assert str(control.failures).find("test_new") != -1
Example #17
0
    def test_looponfail_removed_test(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
            def test_two():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 2

        modcol.fspath.write(py.code.Source("""
            def test_xxx(): # renamed test
                assert 0
            def test_two():
                assert 1 # pass now
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0

        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
Example #18
0
    def test_looponfail_from_one_to_two_tests(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                assert 0
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert 'test_one' in remotecontrol.failures[0]

        modcol.fspath.write(py.code.Source("""
            def test_one():
                assert 1 # passes now
            def test_two():
                assert 0 # new and fails
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 0
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1
        assert 'test_one' not in remotecontrol.failures[0]
        assert 'test_two' in remotecontrol.failures[0]
 def test_failure_subdir_no_init(self, pytester: pytest.Pytester,
                                 monkeypatch: pytest.MonkeyPatch) -> None:
     modcol = pytester.getitem(
         textwrap.dedent("""
             def test_func():
                 assert 0
             """))
     if PYTEST_GTE_7:
         parent = modcol.path.parent.parent  # type: ignore[attr-defined]
     else:
         parent = Path(modcol.fspath.dirpath().dirpath())
     monkeypatch.chdir(parent)
     modcol.config.args = [
         str(Path(x).relative_to(parent)) for x in modcol.config.args
     ]
     control = RemoteControl(modcol.config)
     control.loop_once()
     assert control.failures
     control.loop_once()
     assert control.failures
Example #20
0
    def test_looponfail_from_fail_to_ok(self, testdir):
        modcol = testdir.getmodulecol("""
            def test_one():
                x = 0
                assert x == 1
            def test_two():
                assert 1
        """)
        remotecontrol = RemoteControl(modcol.config)
        remotecontrol.loop_once()
        assert len(remotecontrol.failures) == 1

        modcol.fspath.write(py.code.Source("""
            def test_one():
                assert 1
            def test_two():
                assert 1
        """))
        removepyc(modcol.fspath)
        remotecontrol.loop_once()
        assert not remotecontrol.failures
 def test_nofailures(self, pytester: pytest.Pytester) -> None:
     item = pytester.getitem("def test_func(): pass\n")
     control = RemoteControl(item.config)
     control.setup()
     topdir, failures = control.runsession()[:2]
     assert not failures
Example #22
0
 def test_nofailures(self, testdir):
     item = testdir.getitem("def test_func(): pass\n")
     control = RemoteControl(item.config)
     control.setup()
     topdir, failures = control.runsession()[:2]
     assert not failures
Example #23
0
 def test_nofailures(self, testdir):
     item = testdir.getitem("def test_func(): pass\n")
     control = RemoteControl(item.config)
     control.setup()
     topdir, failures = control.runsession()[:2]
     assert not failures