This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the exception when use __file__ attribute in .py config file.
- Loading branch information
1 parent
e5d48d6
commit fb62756
Showing
4 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters