summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBranden Rolston <branden@tripit.com>2012-08-07 19:21:14 -0700
committerBranden Rolston <branden@tripit.com>2012-08-07 19:21:14 -0700
commit8a52e8edd81fbafe2389a91b4d324e835a05945e (patch)
treee29d5b70b3bc7af1de105622db752f40792f4b09 /tests
parentfb10a92124198aa1b046550926ae6cb8ff1480ee (diff)
downloadvirtualenv-8a52e8edd81fbafe2389a91b4d324e835a05945e.tar.gz
Fix --relocatable when script uses future statements.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_virtualenv.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index 3768db1..51e9728 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -48,3 +48,22 @@ def test_resolve_intepreter_with_invalid_interpreter(mock_exists):
mock_exists.assert_called_with("/usr/bin/python42")
virtualenv.is_executable.assert_called_with("/usr/bin/python42")
+
+
+def test_activate_after_future_statements():
+ """Should insert activation line after last future statement"""
+ script = [
+ '#!/usr/bin/env python',
+ 'from __future__ import with_statement',
+ 'from __future__ import print_function',
+ 'print("Hello, world!")'
+ ]
+ assert virtualenv.relative_script(script) == [
+ '#!/usr/bin/env python',
+ 'from __future__ import with_statement',
+ 'from __future__ import print_function',
+ '',
+ "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); execfile(activate_this, dict(__file__=activate_this)); del os, activate_this",
+ '',
+ 'print("Hello, world!")'
+ ]