Browse Source

Now prints a nice warning instead of failing tests when js2py isn't installed

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.7.8
Erez Sh 5 years ago
parent
commit
f3714a572f
2 changed files with 5 additions and 2 deletions
  1. +1
    -1
      tests/__main__.py
  2. +4
    -1
      tests/test_nearley/test_nearley.py

+ 1
- 1
tests/__main__.py View File

@@ -10,7 +10,7 @@ from .test_reconstructor import TestReconstructor
try:
from .test_nearley.test_nearley import TestNearley
except ImportError:
pass
logging.warn("Warning: Skipping tests for Nearley (js2py required)")

# from .test_selectors import TestSelectors
# from .test_grammars import TestPythonG, TestConfigG


+ 4
- 1
tests/test_nearley/test_nearley.py View File

@@ -15,9 +15,12 @@ NEARLEY_PATH = os.path.join(TEST_PATH, 'nearley')
BUILTIN_PATH = os.path.join(NEARLEY_PATH, 'builtin')

if not os.path.exists(NEARLEY_PATH):
print("Skipping Nearley tests!")
logging.warn("Nearley not installed. Skipping Nearley tests!")
raise ImportError("Skipping Nearley tests!")

import js2py # Ensures that js2py exists, to avoid failing tests


class TestNearley(unittest.TestCase):
def test_css(self):
fn = os.path.join(NEARLEY_PATH, 'examples/csscolor.ne')


Loading…
Cancel
Save