Example #1
0
    def test_main_execution_with_diff(self, capsys):
        sys.argv.extend(['relint.py', 'test_relint.py', '--diff'])
        sys.stdin = open('test.diff')
        with pytest.raises(SystemExit) as exc_info:
            main()

        expected_message = 'Hint: Get it done right away!'

        out, _ = capsys.readouterr()
        assert expected_message in out
        assert exc_info.value.code == 0
Example #2
0
    def test_filename_warning(self, tmpdir):
        tmpdir.join('.relint.yml').write('- name: old\n'
                                         '  pattern: ".*"\n'
                                         '  filename: "*.py"\n')

        with tmpdir.as_cwd():
            with warnings.catch_warnings(record=True) as w:
                with pytest.raises(SystemExit) as exc_info:
                    main(['**'])

        assert exc_info.value.code == 0
        assert issubclass(w[-1].category, DeprecationWarning)
        assert "'filename'" in str(w[-1].message)
Example #3
0
    def test_main_execution_with_diff(self, capsys, mocker, tmpdir):
        tmpdir.join('.relint.yml').write(open('.relint.yml').read())
        tmpdir.join('dummy.py').write("# TODO do something")
        diff = io.StringIO("diff --git a/dummy.py b/dummy.py\n"
                           "@@ -0,0 +1 @@\n"
                           "+# TODO do something")

        mocker.patch.object(sys, 'stdin', diff)

        with tmpdir.as_cwd():
            with pytest.raises(SystemExit) as exc_info:
                main(['relint.py', 'dummy.py', '--diff'])

        expected_message = 'Hint: Get it done right away!'

        out, _ = capsys.readouterr()
        assert expected_message in out
        assert exc_info.value.code == 0
Example #4
0
    def test_main_execution(self, mocker, filename):
        with pytest.raises(SystemExit) as exc_info:
            main(['relint.py', filename])

        assert exc_info.value.code == 0
Example #5
0
    def test_main_execution(self):
        sys.argv.extend(['relint.py', 'test_relint.py'])
        with pytest.raises(SystemExit) as exc_info:
            main()

        assert exc_info.value.code == 0