def test_error(): f = open("setup.py", mode='w') f.write('name="test"') f.close() with pytest.raises(AssertionError, match=r"Invalid setup.py - setup\(\) was not called.*"): modules.main(["list", "--mode", "folder", "--include-parent"])
def test_main(): with mock.patch('sys.stdout', new=StringIO()) as output: modules.main(["list", "--mode", "package-path"]) assert output.getvalue() == ' '.join( [os.path.join("mod1", "pack1"), os.path.join("mod2", "pack2"), ""]) with mock.patch('sys.stdout', new=StringIO()) as output: modules.main(["list", "--mode", "folder", "--include-parent"]) assert output.getvalue() == ' '.join(["mod1", "mod2", ".", ""])
def test_main_replace_version(): with mock.patch('sys.stdout', new=StringIO()) as output: modules.main(["print_version"]) assert output.getvalue() == '1.2.3.dev\n' with mock.patch('sys.stdout', new=StringIO()) as output: modules.main(["replace_version", "--old", "1.2.3.dev", "--new", "1.2.4.dev"]) assert output.getvalue() == 'Successfully replaced version 1.2.3.dev with 1.2.4.dev.\n' with mock.patch('sys.stdout', new=StringIO()) as output: modules.main(["print_version"]) assert output.getvalue() == '1.2.4.dev\n'