lihaoyi/macropy

Unit tests not working

rebcabin opened this issue · 3 comments

Just did a fresh git clone of the repo, then

python run_tests.py

from the project root, as documented. With Python 2.7.10,

Python 2.7.10 (default, Sep 22 2015, 12:25:10) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

I get the following traceback

$ python run_tests.py 
No module named pyxl.codec.tokenizer
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/core/import_hooks.py", line 45, in find_module
    bindings = detect_macros(tree)
  File "/Users/bbeckman/Documents/macropy/macropy/core/macros.py", line 263, in detect_macros
    __import__(stmt.module)
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/pyxl_strings.py", line 6, in <module>
    from pyxl.codec.tokenizer import pyxl_tokenize
ImportError: No module named pyxl.codec.tokenizer
Traceback (most recent call last):
  File "run_tests.py", line 4, in <module>
    import macropy.test
  File "/Users/bbeckman/Documents/macropy/macropy/test/__init__.py", line 16, in <module>
    import macropy.experimental.test
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/__init__.py", line 5, in <module>
    import pyxl_snippets
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 3, in <module>
    from macropy.experimental.pyxl_strings import macros, p
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/pyxl_strings.py", line 6, in <module>
    from pyxl.codec.tokenizer import pyxl_tokenize
ImportError: No module named pyxl.codec.tokenizer

I have not been able to find pyxl.codec.tokenizer:

pip install pyxl
pip install pyxl.codec
pip install pyxl.codec.tokenizer

all fail with errors like the following

Collecting pyxl
  Could not find a version that satisfies the requirement pyxl (from versions: )
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pyxl to allow).
No matching distribution found for pyxl

An attempt to allow external fails differently:

$ pip install --allow-external pyxl
DEPRECATION: --download-cache has been deprecated and will be removed in the future. Pip now automatically uses and configures its cache.
You must give at least one requirement to install (see "pip help install")

This latter appears to be a pilot error (not sure how exactly to use allow-external).

After manually installing pyxl from this location: https://github.com/dropbox/pyxl, I get many successes but a few failures, namely

$ python run_tests.py
.................................E......EEEEE.........................................EE..
======================================================================
ERROR: test_bindings_json (macropy.test.peg.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/test/peg.py", line 372, in test_bindings_json
    json_doc.parse(open(__file__ + "/../peg_json/fail%s.json" % i).read())
IOError: [Errno 20] Not a directory: '/Users/bbeckman/Documents/macropy/macropy/test/peg.py/../peg_json/fail1.json'

======================================================================
ERROR: test_attributes (macropy.experimental.test.pyxl_snippets.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 45, in test_attributes
    fruit = p['<div data-text="tangerine" />']
NameError: global name 'html' is not defined

======================================================================
ERROR: test_dynamic (macropy.experimental.test.pyxl_snippets.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 37, in test_dynamic
    nav = p['<ul />']
NameError: global name 'html' is not defined

======================================================================
ERROR: test_inline_python (macropy.experimental.test.pyxl_snippets.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 23, in test_inline_python
    image = p['<img src="/static/images/{image_name}" />']
NameError: global name 'html' is not defined

======================================================================
ERROR: test_interpreter (macropy.experimental.test.pyxl_snippets.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 57, in test_interpreter
    pyxl_blob = p["""<div class="{unsafe_attr}">
NameError: global name 'html' is not defined

======================================================================
ERROR: test_modules (macropy.experimental.test.pyxl_snippets.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/experimental/test/pyxl_snippets.py", line 86, in test_modules
    content = p['<div>Any arbitrary content...</div>']
NameError: global name 'html' is not defined

======================================================================
ERROR: test_pyc_exporter (macropy.core.test.exporters.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/core/test/exporters/__init__.py", line 33, in test_pyc_exporter
    f = open(__file__ + "/../pyc_cache.py", "a")
IOError: [Errno 20] Not a directory: '/Users/bbeckman/Documents/macropy/macropy/core/test/exporters/__init__.pyc/../pyc_cache.py'

======================================================================
ERROR: test_save_exporter (macropy.core.test.exporters.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bbeckman/Documents/macropy/macropy/core/test/exporters/__init__.py", line 53, in test_save_exporter
    macropy.exporter = SaveExporter(__file__ + "/../exported", __file__ + "/..")
  File "/Users/bbeckman/Documents/macropy/macropy/core/exporters.py", line 20, in __init__
    shutil.copytree(root, directory)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 171, in copytree
    names = os.listdir(src)
OSError: [Errno 20] Not a directory: '/Users/bbeckman/Documents/macropy/macropy/core/test/exporters/__init__.pyc/..'

----------------------------------------------------------------------
Ran 90 tests in 0.103s

FAILED (errors=8)

w.r.t. the first test, I verified that the directory peg_json does exists in the correct place and that the file fail1.json is present.

Please see pull request #71 for best-effort fixes to all unit tests.