From 1914e1a08f2520f57fced02be1f87433422dd0c9 Mon Sep 17 00:00:00 2001 From: wangzhaolin Date: Tue, 19 Nov 2019 02:04:41 +0800 Subject: [PATCH] add _get_config test case. --- tests/commands/test_command.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/commands/test_command.py diff --git a/tests/commands/test_command.py b/tests/commands/test_command.py new file mode 100644 index 00000000..c1eda583 --- /dev/null +++ b/tests/commands/test_command.py @@ -0,0 +1,34 @@ +# -*- coding:utf-8 -*- +import os +import tempfile + +from flexmock import flexmock + +from orator.commands.command import Command + +from . import OratorCommandTestCase + + +class FooCommand(Command): + """ + Test Command + """ + name = 'foo' + + def handle(self): + pass + + +class CommandTestCase(OratorCommandTestCase): + def test_get_py_config_and_require___file__(self): + filename = tempfile.mktemp('.py') + with open(filename, 'w') as f: + f.write('foo = __file__') + + command = flexmock(FooCommand()) + command.should_call('_get_config').and_return({'foo': filename}) + + self.run_command(command, [('-c', filename)]) + + if os.path.exists(filename): + os.remove(filename)