def test_dry_run(capsys): args = ["undebt", "-i", method_to_function_input_path, "-p", method_to_function_path, "--verbose", "--dry-run"] with mock.patch("sys.argv", args): main() out, err = capsys.readouterr() assert err == '>>> {}\n'.format(method_to_function_input_path) assert out == method_to_function_output_contents
def test_no_file(mock_process, mock_load_patterns): fake_patterns = mock.MagicMock() mock_load_patterns.return_value = fake_patterns args = ['undebt', '-p', 'blah'] with mock.patch('sys.argv', args): main.main() mock_process.assert_called_once_with(fake_patterns, None, False)
def test_single_file(): args = [ "undebt", "-p", method_to_function_path, method_to_function_input_path, "--verbose" ] with mock.patch("sys.argv", args): main() assert _read_input_file( ) == method_to_function_output_contents == _read_output_file()
def test_directory(): args = [ "undebt", "-i", tests_inputs_directory, "-p", method_to_function_path, "-e", "txt", "--verbose" ] with mock.patch("sys.argv", args): main() assert _read_input_file( ) == method_to_function_output_contents == _read_output_file()
def test_loading_pattern_with_module_name(): # Need full module name here import undebt.examples.method_to_function module_name = undebt.examples.method_to_function.__name__ args = [ "undebt", "-p", module_name, method_to_function_input_path, "--verbose" ] with mock.patch("sys.argv", args): main() assert _read_input_file( ) == method_to_function_output_contents == _read_output_file()
def test_dry_run(capsys): args = [ "-p", method_to_function.__name__, "--dry-run", method_to_function_input_path, "--verbose", ] main.main(args) out, err = capsys.readouterr() assert err == '>>> {}\n'.format(method_to_function_input_path) assert out == method_to_function_output_contents
def test_loading_pattern_with_module_name(): args = [ "undebt", "-p", method_to_function.__name__, method_to_function_input_path, "--verbose", ] with mock.patch("sys.argv", args): main.main() assert (_read_input_file() == method_to_function_output_contents == _read_output_file())
def test_loading_pattern_with_module_name(): args = [ "-p", method_to_function.__name__, method_to_function_input_path, "--verbose", ] main.main(args) assert ( _read_input_file() == method_to_function_output_contents == _read_output_file() )
def test_no_file(mock_file_processor): args = ['undebt', '-p', method_to_function_path] with mock.patch('sys.argv', args): main() mock_file_processor().assert_called_once_with(None)
def test_no_file(mock_process, mock_load_patterns): fake_patterns = mock.MagicMock() mock_load_patterns.return_value = fake_patterns args = ['-p', 'blah'] main.main(args) mock_process.assert_called_once_with(fake_patterns, None, False)
# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function from undebt.cmd.main import main if __name__ == "__main__": main()