diff --git a/__root__/doc/HACKING b/__root__/doc/HACKING index 058dc0b..8b32606 100644 --- a/__root__/doc/HACKING +++ b/__root__/doc/HACKING @@ -154,11 +154,11 @@ Interactive/exploratory use: IPython and friends For top-level modules, following prologue can be used: - import os.path as op; execfile(op.join('tests', '_bootstrap.py')) + execfile('_go') or alternatively add this command-line option to ipython invocation: - ipython --InteractiveShellApp.exec_files='["tests/_bootstrap.py"]' + ipython --InteractiveShellApp.exec_files='["_go"]' and from now on, one can use relative imports conveniently: diff --git a/__root__/run-dev b/__root__/run-dev index b74ba3c..a63388d 100755 --- a/__root__/run-dev +++ b/__root__/run-dev @@ -24,8 +24,9 @@ script_path = get_script_path() real_script_path = realpath(script_path) -if __name__ != '__main__': - # when execfile'd from tests, verbose logging desired +if (basename(real_script_path) != basename(sys.path[0]) + and 'LOGSKIP' not in globals()): + # when execfile'd from tests or so, verbose logging desired from os import environ import logging logging.basicConfig() @@ -61,7 +62,7 @@ if __package__ not in sys.modules: sys.modules[__package__] = pkg if __name__ == '__main__': - if basename(script_path) == 'run-dev': + if basename(real_script_path) == basename(sys.argv[0]): # __file__ undef? from .main import run sys.exit(run(sys.argv)) diff --git a/_go b/_go new file mode 120000 index 0000000..a0e026e --- /dev/null +++ b/_go @@ -0,0 +1 @@ +run-dev \ No newline at end of file diff --git a/tests/_bootstrap.py b/tests/_bootstrap.py deleted file mode 120000 index 6a45d62..0000000 --- a/tests/_bootstrap.py +++ /dev/null @@ -1 +0,0 @@ -../run-dev \ No newline at end of file diff --git a/tests/_common.py b/tests/_common.py index 5b63be5..77dc11a 100644 --- a/tests/_common.py +++ b/tests/_common.py @@ -6,7 +6,7 @@ __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase diff --git a/tests/_go b/tests/_go new file mode 120000 index 0000000..38c3a2d --- /dev/null +++ b/tests/_go @@ -0,0 +1 @@ +../_go \ No newline at end of file diff --git a/tests/_bootstart.py b/tests/_gone similarity index 100% rename from tests/_bootstart.py rename to tests/_gone diff --git a/tests/ccs2coroxml.py b/tests/ccs2coroxml.py index 380a1a4..5aebc8a 100644 --- a/tests/ccs2coroxml.py +++ b/tests/ccs2coroxml.py @@ -20,4 +20,4 @@ def test01(self): print out_obj('bytestring') -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/ccs2needle_xslt.py b/tests/ccs2needle_xslt.py index f11ac5e..42c8ca3 100644 --- a/tests/ccs2needle_xslt.py +++ b/tests/ccs2needle_xslt.py @@ -5,7 +5,7 @@ """Testing destilling XSLT from the sparse tree-organized snippets""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -41,5 +41,4 @@ def testXSLTTemplate2(self): assert not isinstance(r, list) - -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/command.py b/tests/command.py index e83f4e0..a2f2be9 100644 --- a/tests/command.py +++ b/tests/command.py @@ -5,7 +5,7 @@ """Testing command""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -122,4 +122,4 @@ def cmd_chain_nonmatch_03(cmd_ctxt, continue -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/command_context.py b/tests/command_context.py index b8ac0c1..1fe2925 100644 --- a/tests/command_context.py +++ b/tests/command_context.py @@ -5,7 +5,7 @@ """Testing command context""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -58,4 +58,4 @@ def testPreventedTaintTransitive(self): self.assertTrue(ccb['a']['b'] == 43) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/command_manager.py b/tests/command_manager.py index d346cba..685629d 100644 --- a/tests/command_manager.py +++ b/tests/command_manager.py @@ -5,7 +5,7 @@ """Testing command manager""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -32,4 +32,4 @@ def test_default(self): self.assertEqual(cls, type(commands[cls.name])) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/filter.py b/tests/filter.py index da36e20..1e31d7b 100644 --- a/tests/filter.py +++ b/tests/filter.py @@ -5,7 +5,7 @@ """Testing filter""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -67,4 +67,4 @@ def testXSLTTemplate(self): self.assertTrue(ret == RESULT_DIRECT_XSLT) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/filter_manager.py b/tests/filter_manager.py index b72af44..36773da 100644 --- a/tests/filter_manager.py +++ b/tests/filter_manager.py @@ -5,7 +5,7 @@ """Testing filter manager""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -94,4 +94,4 @@ def test_run_double_ccs2ccsflat(self): norm_whitespace(f.read())) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/format.py b/tests/format.py index 7691905..2eeb569 100644 --- a/tests/format.py +++ b/tests/format.py @@ -5,7 +5,7 @@ """Testing format""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from os.path import dirname, join @@ -93,4 +93,4 @@ def testRngExplicitValidationFail(self): self.assertTrue(entries) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/format_manager.py b/tests/format_manager.py index 9478ccd..0fb560f 100644 --- a/tests/format_manager.py +++ b/tests/format_manager.py @@ -5,7 +5,7 @@ """Testing format manager""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -52,4 +52,4 @@ def test_injection(self): self.assertEqual(fmt_cls, formats[fmt_id]) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/run_cmd.py b/tests/run_cmd.py index 7e701b5..0d83bfd 100644 --- a/tests/run_cmd.py +++ b/tests/run_cmd.py @@ -5,7 +5,7 @@ """Testing direct command run (e.g., when clufter used as a library)""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -72,4 +72,4 @@ def testCcs2PcsNeedleBetter(self): #pprint(outputs['coro']['passout']) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/utils.py b/tests/utils.py index cb14208..d779763 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -5,7 +5,7 @@ """Testing utils module""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -40,4 +40,4 @@ def test_generator(self): self.assertEqual(len(varnames), 2) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/utils_cib.py b/tests/utils_cib.py index d739a66..6e8ac9f 100644 --- a/tests/utils_cib.py +++ b/tests/utils_cib.py @@ -5,7 +5,7 @@ """Testing CIB helpers""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -25,4 +25,4 @@ def test_xsl_attrs_systemd(self): self.assertTrue(rs.res_type == 'smb') -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone')) diff --git a/tests/utils_xml.py b/tests/utils_xml.py index ab36c57..681b8a7 100644 --- a/tests/utils_xml.py +++ b/tests/utils_xml.py @@ -5,7 +5,7 @@ """Testing XML helpers""" __author__ = "Jan Pokorný " -import os.path as op; execfile(op.join(op.dirname(__file__), '_bootstrap.py')) +from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go')) from unittest import TestCase @@ -34,4 +34,4 @@ def test_rng_pivot(self): self.assertTrue(etree.tostring(et) == expected) -execfile(op.join(op.dirname(__file__), '_bootstart.py')) +from os.path import join, dirname as d; execfile(join(d(__file__), '_gone'))