def test_setup_entry(reset_sys_argv): """Setup's entry is a bit different.""" sys.argv = ["py-setup"] with mock.patch.object(commands, "get_config") as patched_config: commands.setup() patched_config.assert_called_once_with()
def test_setup_entry__location(reset_sys_argv): """Any additonal arguments should be treated as a filepath.""" sys.argv = ["py-test", "somewhere/on/your/fs"] with mock.patch.object(commands, "get_config") as patched_config: commands.setup() patched_config.assert_called_once_with("somewhere/on/your/fs")
def test_setup_entry__version(reset_sys_argv, flag): """Ensure the VERSION static is raised with SystemExit when requested.""" sys.argv = ["py-test", flag] with pytest.raises(SystemExit) as patched_exit: commands.setup() assert patched_exit.value.args[0] == pypackage.VERSION
def test_setup_entry__multilocations(reset_sys_argv): """All additonal arguments should be treated as a filepath.""" sys.argv = ["py-test", "place1", "place2"] with mock.patch.object(commands, "get_config") as patched_config: commands.setup() patched_config.assert_any_call("place1") patched_config.assert_any_call("place2") assert patched_config.call_count == 2
def test_setup_entry__help(reset_sys_argv, flag): """Ensure we get the docstring as exit help if the flag is set.""" sys.argv = ["py-setup", flag] with pytest.raises(SystemExit) as patched_exit: commands.setup() for line in commands.setup.__doc__.splitlines(): line = line.strip() if line: assert line in patched_exit.value.args[0]