summaryrefslogtreecommitdiff
path: root/tests/pyscript/environment.py
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2020-02-20 20:36:33 -0700
committerkotfu <kotfu@kotfu.net>2020-02-20 20:36:33 -0700
commitf0c3cbffa35dfe26b8ac54ea1450ed50ba787c9a (patch)
tree03b0e85aaaccc0706caf5658446dda0a5a13cd9f /tests/pyscript/environment.py
parent1e57b0c451de23338378f44088118648848cc82c (diff)
parent22de85832e877b5b360eeacd4b71e00f69bf00e1 (diff)
downloadcmd2-git-f0c3cbffa35dfe26b8ac54ea1450ed50ba787c9a.tar.gz
Merge branch 'master' into api_docs
# Conflicts: # CHANGELOG.md # cmd2/__init__.py # cmd2/decorators.py # docs/api/utility_functions.rst
Diffstat (limited to 'tests/pyscript/environment.py')
-rw-r--r--tests/pyscript/environment.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/pyscript/environment.py b/tests/pyscript/environment.py
new file mode 100644
index 00000000..5e4d93d6
--- /dev/null
+++ b/tests/pyscript/environment.py
@@ -0,0 +1,20 @@
+# flake8: noqa F821
+# Tests that cmd2 populates __name__, __file__, and sets sys.path[0] to our directory
+import os
+import sys
+app.cmd_echo = True
+
+if __name__ != '__main__':
+ print("Error: __name__ is: {}".format(__name__))
+ quit()
+
+if __file__ != sys.argv[0]:
+ print("Error: __file__ is: {}".format(__file__))
+ quit()
+
+our_dir = os.path.dirname(os.path.abspath(__file__))
+if our_dir != sys.path[0]:
+ print("Error: our_dir is: {}".format(our_dir))
+ quit()
+
+print("PASSED")