diff --git a/CHANGES b/CHANGES index aefb2f90..0a889159 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,13 @@ maintained as a mature library. No new major features are planned, but issues reported for bugs are still welcome. Any changes to the software will be noted here. +Version 2022.10.27 +------------------ +10/27/22 Reoganization/modernization of the build process. PLY continues + to make no package-installable releases. However, you can now + use the Makefile to build artifacts installable via pip. + Use `make test` to test and `make build` to build. + Version 2022_01_02 ------------------ 12/12/21 PLY is no longer being developed in public. Instead diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..cfcf7714 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include Makefile CONTRIBUTING.md +recursive-include example * +recursive-include tests * +recursive-include docs * diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..683f97c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +PYTHON=python3 +VENV=.venv + +# Setup and install all of the required tools for building, testing, +# and deploying +setup:: + rm -rf $(VENV) + $(PYTHON) -m venv $(VENV) + ./$(VENV)/bin/python -m pip install pytest + ./$(VENV)/bin/python -m pip install pytest-cov + ./$(VENV)/bin/python -m pip install build + ./$(VENV)/bin/python -m pip install twine + +# Run unit tests +test:: + ./$(VENV)/bin/python -m pip install . + ./$(VENV)/bin/python tests/testlex.py + ./$(VENV)/bin/python tests/testyacc.py + +# Build an artifact suitable for installing with pip +build:: + ./$(VENV)/bin/python -m build + +# Install into the default Python +install:: + $(PYTHON) -m pip install . diff --git a/README.md b/README.md index 473e6d35..9e4e3f9f 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,17 @@ flexibility in terms of how you decide to use it. You can use PLY to build Abstract Syntax Trees (ASTs), simple one-pass compilers, protocol decoders, or even a more advanced parsing framework. -## Important Notice - October 11, 2022 +## Important Notice - October 27, 2022 -I'm officially retiring the PLY project. There will be no further -releases. Should you choose to still use it, the GitHub repo will -remain alive--feel free to vendor the code and report bugs as you see -fit. I'd like to thank everyone who contributed to the -project over the last twenty-one years. -- Dave +The PLY project will make no further package-installable releases. +If you want the latest version, you'll need to download it here +or clone the repo. -## Download - -* [Current Release (ply-2022_01_02)](https://github.com/dabeaz/ply/raw/master/ply-2022_01_02.tar.gz) -* [Historial Releases](https://github.com/dabeaz/archive/tree/main/ply) +## Requirements The current release of PLY requires the use of Python 3.6 or greater. If you need to support an older version, download one of the -historical releases. +historical releases at https://github.com/dabeaz/archive/tree/main/ply. ## How to Install and Use diff --git a/ply-2022_01_02.tar.gz b/ply-2022_01_02.tar.gz deleted file mode 100644 index b464a14f..00000000 Binary files a/ply-2022_01_02.tar.gz and /dev/null differ diff --git a/ply-tests.tar.gz b/ply-tests.tar.gz deleted file mode 100644 index 8ffa1aa1..00000000 Binary files a/ply-tests.tar.gz and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9787c3bd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..b4ba4edb --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[metadata] +name = ply +version = 2022.10.27 +url = https://github.com/dabeaz/ply +author = David Beazley +author_email = "David Beazley" +description = "PLY - Sly Lex Yacc" +long_description = "PLY is an implementation of lex and yacc. No longer maintained on PyPI. Latest version on GitHub." +license = MIT +license_files = LICENSE +classifiers = + License :: OSI Approved :: MIT License + +[options] +package_dir = + =src + +packages = ply diff --git a/ply/__init__.py b/src/ply/__init__.py similarity index 76% rename from ply/__init__.py rename to src/ply/__init__.py index 0ef83ef1..45f28c5b 100644 --- a/ply/__init__.py +++ b/src/ply/__init__.py @@ -2,4 +2,4 @@ # Author: David Beazley (dave@dabeaz.com) # https://github.com/dabeaz/ply -__version__ = '2022_01_02' +__version__ = '2022.10.27' diff --git a/ply/lex.py b/src/ply/lex.py similarity index 100% rename from ply/lex.py rename to src/ply/lex.py diff --git a/ply/yacc.py b/src/ply/yacc.py similarity index 100% rename from ply/yacc.py rename to src/ply/yacc.py diff --git a/test/testcpp.py b/test/testcpp.py deleted file mode 100644 index dbfb3e4d..00000000 --- a/test/testcpp.py +++ /dev/null @@ -1,153 +0,0 @@ -from unittest import TestCase, main - -from multiprocessing import Process, Queue -from six.moves.queue import Empty - -import sys -import locale - -if ".." not in sys.path: - sys.path.insert(0, "..") - -from ply.lex import lex -from ply.cpp import * - - -def preprocessing(in_, out_queue): - out = None - - try: - p = Preprocessor(lex()) - p.parse(in_) - tokens = [t.value for t in p.parser] - out = "".join(tokens) - finally: - out_queue.put(out) - -class CPPTests(TestCase): - "Tests related to ANSI-C style lexical preprocessor." - - def __test_preprocessing(self, in_, expected, time_limit = 1.0): - out_queue = Queue() - - preprocessor = Process( - name = "PLY`s C preprocessor", - target = preprocessing, - args = (in_, out_queue) - ) - - preprocessor.start() - - try: - out = out_queue.get(timeout = time_limit) - except Empty: - preprocessor.terminate() - raise RuntimeError("Time limit exceeded!") - else: - self.assertMultiLineEqual(out, expected) - - def test_infinite_argument_expansion(self): - # CPP does not drags set of currently expanded macros through macro - # arguments expansion. If there is a match between an argument value - # and name of an already expanded macro then CPP falls into infinite - # recursion. - self.__test_preprocessing("""\ -#define a(x) x -#define b a(b) -b -""" , """\ - - -b""" - ) - - - def test_concatenation(self): - self.__test_preprocessing("""\ -#define a(x) x##_ -#define b(x) _##x -#define c(x) _##x##_ -#define d(x,y) _##x##y##_ - -a(i) -b(j) -c(k) -d(q,s)""" - , """\ - - - - - -i_ -_j -_k_ -_qs_""" - ) - - def test_deadloop_macro(self): - # If there is a word which equals to name of a parametrized macro, then - # attempt to expand such word as a macro manages the parser to fall - # into an infinite loop. - - self.__test_preprocessing("""\ -#define a(x) x - -a;""" - , """\ - - -a;""" - ) - - def test_index_error(self): - # If there are no tokens after a word ("a") which equals to name of - # a parameterized macro, then attempt to expand this word leads to - # IndexError. - - self.__test_preprocessing("""\ -#define a(x) x - -a""" - , """\ - - -a""" - ) - - def test_evalexpr(self): - # #if 1 != 2 is not processed correctly; undefined values are converted - # to 0L instead of 0 (issue #195) - # - self.__test_preprocessing("""\ -#if (1!=0) && (!x || (!(1==2))) -a; -#else -b; -#endif -""" - , """\ - -a; - -""" - ) - - def test_include_nonascii(self): - # Issue #196: #included files are read using the current locale's - # getdefaultencoding. if a #included file contains non-ascii characters, - # while default encoding is e.g. US_ASCII, this causes an error - locale.setlocale(locale.LC_ALL, 'C') - self.__test_preprocessing("""\ -#include "test_cpp_nonascii.c" -x; - -""" - , """\ - - -1; -""" - ) - -main() diff --git a/test/README b/tests/README similarity index 100% rename from test/README rename to tests/README diff --git a/test/calclex.py b/tests/calclex.py similarity index 93% rename from test/calclex.py rename to tests/calclex.py index 030a9863..48627535 100644 --- a/test/calclex.py +++ b/tests/calclex.py @@ -1,9 +1,6 @@ # ----------------------------------------------------------------------------- # calclex.py # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.lex as lex tokens = ( diff --git a/test/cleanup.sh b/tests/cleanup.sh similarity index 100% rename from test/cleanup.sh rename to tests/cleanup.sh diff --git a/test/lex_closure.py b/tests/lex_closure.py similarity index 94% rename from test/lex_closure.py rename to tests/lex_closure.py index 30ee6791..0b34cff8 100644 --- a/test/lex_closure.py +++ b/tests/lex_closure.py @@ -1,9 +1,6 @@ # ----------------------------------------------------------------------------- # lex_closure.py # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.lex as lex tokens = ( diff --git a/test/lex_doc1.py b/tests/lex_doc1.py similarity index 78% rename from test/lex_doc1.py rename to tests/lex_doc1.py index 8a2bfcce..4b626090 100644 --- a/test/lex_doc1.py +++ b/tests/lex_doc1.py @@ -2,9 +2,6 @@ # # Missing documentation string -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_dup1.py b/tests/lex_dup1.py similarity index 79% rename from test/lex_dup1.py rename to tests/lex_dup1.py index fd04cdb7..b9dc3c52 100644 --- a/test/lex_dup1.py +++ b/tests/lex_dup1.py @@ -2,9 +2,6 @@ # # Duplicated rule specifiers -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_dup2.py b/tests/lex_dup2.py similarity index 81% rename from test/lex_dup2.py rename to tests/lex_dup2.py index 870e5e7d..47bf5b50 100644 --- a/test/lex_dup2.py +++ b/tests/lex_dup2.py @@ -2,9 +2,6 @@ # # Duplicated rule specifiers -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_dup3.py b/tests/lex_dup3.py similarity index 80% rename from test/lex_dup3.py rename to tests/lex_dup3.py index 94b5592e..5398f485 100644 --- a/test/lex_dup3.py +++ b/tests/lex_dup3.py @@ -2,9 +2,6 @@ # # Duplicated rule specifiers -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_empty.py b/tests/lex_empty.py similarity index 68% rename from test/lex_empty.py rename to tests/lex_empty.py index e0368bfa..d0baf310 100644 --- a/test/lex_empty.py +++ b/tests/lex_empty.py @@ -2,9 +2,6 @@ # # No rules defined -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_error1.py b/tests/lex_error1.py similarity index 75% rename from test/lex_error1.py rename to tests/lex_error1.py index 4508a808..fec02822 100644 --- a/test/lex_error1.py +++ b/tests/lex_error1.py @@ -2,9 +2,6 @@ # # Missing t_error() rule -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_error2.py b/tests/lex_error2.py similarity index 77% rename from test/lex_error2.py rename to tests/lex_error2.py index 8040d390..8914ab63 100644 --- a/test/lex_error2.py +++ b/tests/lex_error2.py @@ -2,9 +2,6 @@ # # t_error defined, but not function -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_error3.py b/tests/lex_error3.py similarity index 79% rename from test/lex_error3.py rename to tests/lex_error3.py index 1feefb64..71ca9038 100644 --- a/test/lex_error3.py +++ b/tests/lex_error3.py @@ -2,9 +2,6 @@ # # t_error defined as function, but with wrong # args -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_error4.py b/tests/lex_error4.py similarity index 79% rename from test/lex_error4.py rename to tests/lex_error4.py index f4f48db1..53878082 100644 --- a/test/lex_error4.py +++ b/tests/lex_error4.py @@ -2,9 +2,6 @@ # # t_error defined as function, but too many args -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_hedit.py b/tests/lex_hedit.py similarity index 94% rename from test/lex_hedit.py rename to tests/lex_hedit.py index 34f15a17..9f724d02 100644 --- a/test/lex_hedit.py +++ b/tests/lex_hedit.py @@ -13,8 +13,6 @@ # This example shows how to modify the state of the lexer to parse # such tokens # ----------------------------------------------------------------------------- -import sys -if ".." not in sys.path: sys.path.insert(0,"..") import ply.lex as lex diff --git a/test/lex_ignore.py b/tests/lex_ignore.py similarity index 81% rename from test/lex_ignore.py rename to tests/lex_ignore.py index 6c43b4cf..b31fb399 100644 --- a/test/lex_ignore.py +++ b/tests/lex_ignore.py @@ -2,9 +2,6 @@ # # Improperly specific ignore declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_ignore2.py b/tests/lex_ignore2.py similarity index 80% rename from test/lex_ignore2.py rename to tests/lex_ignore2.py index f60987a6..de0958a4 100644 --- a/test/lex_ignore2.py +++ b/tests/lex_ignore2.py @@ -2,9 +2,6 @@ # # ignore declaration as a raw string -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_literal1.py b/tests/lex_literal1.py similarity index 77% rename from test/lex_literal1.py rename to tests/lex_literal1.py index db389c37..510b3798 100644 --- a/test/lex_literal1.py +++ b/tests/lex_literal1.py @@ -2,9 +2,6 @@ # # Bad literal specification -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_literal2.py b/tests/lex_literal2.py similarity index 76% rename from test/lex_literal2.py rename to tests/lex_literal2.py index b50b92cd..a7a2c56d 100644 --- a/test/lex_literal2.py +++ b/tests/lex_literal2.py @@ -2,9 +2,6 @@ # # Bad literal specification -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_literal3.py b/tests/lex_literal3.py similarity index 81% rename from test/lex_literal3.py rename to tests/lex_literal3.py index 91ab980c..9d697c92 100644 --- a/test/lex_literal3.py +++ b/tests/lex_literal3.py @@ -3,9 +3,6 @@ # An empty literal specification given as a list # Issue 8 : Literals empty list causes IndexError -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_many_tokens.py b/tests/lex_many_tokens.py similarity index 90% rename from test/lex_many_tokens.py rename to tests/lex_many_tokens.py index 81ae57a2..02e3a111 100644 --- a/test/lex_many_tokens.py +++ b/tests/lex_many_tokens.py @@ -4,8 +4,6 @@ # 100-group limit of the re module) import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = ["TOK%d" % i for i in range(1000)] diff --git a/test/lex_module.py b/tests/lex_module.py similarity index 67% rename from test/lex_module.py rename to tests/lex_module.py index 8bdd3ed4..0fa85442 100644 --- a/test/lex_module.py +++ b/tests/lex_module.py @@ -1,9 +1,6 @@ # lex_module.py # -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex import lex_module_import lex.lex(module=lex_module_import) diff --git a/test/lex_module_import.py b/tests/lex_module_import.py similarity index 100% rename from test/lex_module_import.py rename to tests/lex_module_import.py diff --git a/test/lex_object.py b/tests/lex_object.py similarity index 94% rename from test/lex_object.py rename to tests/lex_object.py index 7e9f389d..2fa75376 100644 --- a/test/lex_object.py +++ b/tests/lex_object.py @@ -1,9 +1,7 @@ # ----------------------------------------------------------------------------- # lex_object.py # ----------------------------------------------------------------------------- -import sys -if ".." not in sys.path: sys.path.insert(0,"..") import ply.lex as lex class CalcLexer: diff --git a/test/lex_re1.py b/tests/lex_re1.py similarity index 78% rename from test/lex_re1.py rename to tests/lex_re1.py index 5be7aefc..d6b7c389 100644 --- a/test/lex_re1.py +++ b/tests/lex_re1.py @@ -2,9 +2,6 @@ # # Bad regular expression in a string -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_re2.py b/tests/lex_re2.py similarity index 79% rename from test/lex_re2.py rename to tests/lex_re2.py index 8dfb8e3f..f5ce6957 100644 --- a/test/lex_re2.py +++ b/tests/lex_re2.py @@ -2,9 +2,6 @@ # # Regular expression rule matches empty string -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_re3.py b/tests/lex_re3.py similarity index 81% rename from test/lex_re3.py rename to tests/lex_re3.py index e1799253..8f594f37 100644 --- a/test/lex_re3.py +++ b/tests/lex_re3.py @@ -2,9 +2,6 @@ # # Regular expression rule matches empty string -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_rule1.py b/tests/lex_rule1.py similarity index 79% rename from test/lex_rule1.py rename to tests/lex_rule1.py index 0406c6f3..ae279e9e 100644 --- a/test/lex_rule1.py +++ b/tests/lex_rule1.py @@ -2,9 +2,6 @@ # # Rule function with incorrect number of arguments -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_rule2.py b/tests/lex_rule2.py similarity index 80% rename from test/lex_rule2.py rename to tests/lex_rule2.py index 1c29d873..adefee24 100644 --- a/test/lex_rule2.py +++ b/tests/lex_rule2.py @@ -2,9 +2,6 @@ # # Rule function with incorrect number of arguments -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_rule3.py b/tests/lex_rule3.py similarity index 81% rename from test/lex_rule3.py rename to tests/lex_rule3.py index 9ea94da2..bd61040f 100644 --- a/test/lex_rule3.py +++ b/tests/lex_rule3.py @@ -2,9 +2,6 @@ # # Rule function with incorrect number of arguments -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state1.py b/tests/lex_state1.py similarity index 88% rename from test/lex_state1.py rename to tests/lex_state1.py index 7528c915..6fa5e9fc 100644 --- a/test/lex_state1.py +++ b/tests/lex_state1.py @@ -2,9 +2,6 @@ # # Bad state declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state2.py b/tests/lex_state2.py similarity index 88% rename from test/lex_state2.py rename to tests/lex_state2.py index 3aef69ea..9300ed7b 100644 --- a/test/lex_state2.py +++ b/tests/lex_state2.py @@ -2,9 +2,6 @@ # # Bad state declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state3.py b/tests/lex_state3.py similarity index 89% rename from test/lex_state3.py rename to tests/lex_state3.py index 616e4847..2e5b7cf2 100644 --- a/test/lex_state3.py +++ b/tests/lex_state3.py @@ -2,9 +2,6 @@ # # Bad state declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state4.py b/tests/lex_state4.py similarity index 88% rename from test/lex_state4.py rename to tests/lex_state4.py index 18250161..fb147c81 100644 --- a/test/lex_state4.py +++ b/tests/lex_state4.py @@ -2,9 +2,6 @@ # # Bad state declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state5.py b/tests/lex_state5.py similarity index 89% rename from test/lex_state5.py rename to tests/lex_state5.py index 4ce828e4..fb2f3a74 100644 --- a/test/lex_state5.py +++ b/tests/lex_state5.py @@ -2,9 +2,6 @@ # # Bad state declaration -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state_noerror.py b/tests/lex_state_noerror.py similarity index 89% rename from test/lex_state_noerror.py rename to tests/lex_state_noerror.py index 90bbea87..54b892e4 100644 --- a/test/lex_state_noerror.py +++ b/tests/lex_state_noerror.py @@ -2,9 +2,6 @@ # # Declaration of a state for which no rules are defined -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state_norule.py b/tests/lex_state_norule.py similarity index 89% rename from test/lex_state_norule.py rename to tests/lex_state_norule.py index 64ec6d3e..4b979b22 100644 --- a/test/lex_state_norule.py +++ b/tests/lex_state_norule.py @@ -2,9 +2,6 @@ # # Declaration of a state for which no rules are defined -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_state_try.py b/tests/lex_state_try.py similarity index 91% rename from test/lex_state_try.py rename to tests/lex_state_try.py index fd5ba222..c5f34485 100644 --- a/test/lex_state_try.py +++ b/tests/lex_state_try.py @@ -2,9 +2,6 @@ # # Declaration of a state for which no rules are defined -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_token1.py b/tests/lex_token1.py similarity index 73% rename from test/lex_token1.py rename to tests/lex_token1.py index 6fca300b..1001a99c 100644 --- a/test/lex_token1.py +++ b/tests/lex_token1.py @@ -2,9 +2,6 @@ # # Tests for absence of tokens variable -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex t_PLUS = r'\+' diff --git a/test/lex_token2.py b/tests/lex_token2.py similarity index 75% rename from test/lex_token2.py rename to tests/lex_token2.py index 6e65ab0f..00e758b5 100644 --- a/test/lex_token2.py +++ b/tests/lex_token2.py @@ -2,9 +2,6 @@ # # Tests for tokens of wrong type -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = "PLUS MINUS NUMBER" diff --git a/test/lex_token3.py b/tests/lex_token3.py similarity index 79% rename from test/lex_token3.py rename to tests/lex_token3.py index 636452ea..3b71b3ac 100644 --- a/test/lex_token3.py +++ b/tests/lex_token3.py @@ -2,9 +2,6 @@ # # tokens is right type, but is missing a token for one rule -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_token4.py b/tests/lex_token4.py similarity index 77% rename from test/lex_token4.py rename to tests/lex_token4.py index 52947e9c..89bc2e2b 100644 --- a/test/lex_token4.py +++ b/tests/lex_token4.py @@ -2,9 +2,6 @@ # # Bad token name -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/lex_token_dup.py b/tests/lex_token_dup.py similarity index 80% rename from test/lex_token_dup.py rename to tests/lex_token_dup.py index 384f4e9d..631535f8 100644 --- a/test/lex_token_dup.py +++ b/tests/lex_token_dup.py @@ -2,9 +2,6 @@ # # Duplicate token name in tokens -import sys -if ".." not in sys.path: sys.path.insert(0,"..") - import ply.lex as lex tokens = [ diff --git a/test/test_cpp_nonascii.c b/tests/test_cpp_nonascii.c similarity index 100% rename from test/test_cpp_nonascii.c rename to tests/test_cpp_nonascii.c diff --git a/test/testlex.py b/tests/testlex.py similarity index 95% rename from test/testlex.py rename to tests/testlex.py index a41fda8e..7f2adada 100755 --- a/test/testlex.py +++ b/tests/testlex.py @@ -11,7 +11,6 @@ import warnings import platform -sys.path.insert(0,"..") sys.tracebacklimit = 0 import ply.lex @@ -98,24 +97,24 @@ def test_lex_doc1(self): self.assertRaises(SyntaxError,run_import,"lex_doc1") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_doc1.py:18: No regular expression defined for rule 't_NUMBER'\n")) + "lex_doc1.py:15: No regular expression defined for rule 't_NUMBER'\n")) def test_lex_dup1(self): self.assertRaises(SyntaxError,run_import,"lex_dup1") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_dup1.py:20: Rule t_NUMBER redefined. Previously defined on line 18\n" )) + "lex_dup1.py:17: Rule t_NUMBER redefined. Previously defined on line 15\n" )) def test_lex_dup2(self): self.assertRaises(SyntaxError,run_import,"lex_dup2") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_dup2.py:22: Rule t_NUMBER redefined. Previously defined on line 18\n" )) + "lex_dup2.py:19: Rule t_NUMBER redefined. Previously defined on line 15\n" )) def test_lex_dup3(self): self.assertRaises(SyntaxError,run_import,"lex_dup3") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_dup3.py:20: Rule t_NUMBER redefined. Previously defined on line 18\n" )) + "lex_dup3.py:17: Rule t_NUMBER redefined. Previously defined on line 15\n" )) def test_lex_empty(self): self.assertRaises(SyntaxError,run_import,"lex_empty") @@ -141,19 +140,19 @@ def test_lex_error3(self): self.assertRaises(SyntaxError,run_import,"lex_error3") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_error3.py:20: Rule 't_error' requires an argument\n")) + "lex_error3.py:17: Rule 't_error' requires an argument\n")) def test_lex_error4(self): self.assertRaises(SyntaxError,run_import,"lex_error4") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_error4.py:20: Rule 't_error' has too many arguments\n")) + "lex_error4.py:17: Rule 't_error' has too many arguments\n")) def test_lex_ignore(self): self.assertRaises(SyntaxError,run_import,"lex_ignore") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_ignore.py:20: Rule 't_ignore' must be defined as a string\n")) + "lex_ignore.py:17: Rule 't_ignore' must be defined as a string\n")) def test_lex_ignore2(self): run_import("lex_ignore2") @@ -206,13 +205,13 @@ def test_lex_rule2(self): self.assertRaises(SyntaxError,run_import,"lex_rule2") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_rule2.py:18: Rule 't_NUMBER' requires an argument\n")) + "lex_rule2.py:15: Rule 't_NUMBER' requires an argument\n")) def test_lex_rule3(self): self.assertRaises(SyntaxError,run_import,"lex_rule3") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "lex_rule3.py:18: Rule 't_NUMBER' has too many arguments\n")) + "lex_rule3.py:15: Rule 't_NUMBER' has too many arguments\n")) def test_lex_state1(self): diff --git a/test/testyacc.py b/tests/testyacc.py similarity index 92% rename from test/testyacc.py rename to tests/testyacc.py index c52d0acf..b488bf74 100644 --- a/test/testyacc.py +++ b/tests/testyacc.py @@ -12,7 +12,6 @@ import re import platform -sys.path.insert(0,"..") sys.tracebacklimit = 0 import ply.yacc @@ -105,8 +104,8 @@ def test_yacc_badid(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badid") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_badid.py:32: Illegal name 'bad&rule' in rule 'statement'\n" - "yacc_badid.py:36: Illegal rule name 'bad&rule'\n" + "yacc_badid.py:29: Illegal name 'bad&rule' in rule 'statement'\n" + "yacc_badid.py:33: Illegal rule name 'bad&rule'\n" )) def test_yacc_badprec(self): @@ -137,10 +136,10 @@ def test_yacc_badrule(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_badrule") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_badrule.py:24: Syntax error. Expected ':'\n" - "yacc_badrule.py:28: Syntax error in rule 'statement'\n" - "yacc_badrule.py:33: Syntax error. Expected ':'\n" - "yacc_badrule.py:42: Syntax error. Expected ':'\n" + "yacc_badrule.py:21: Syntax error. Expected ':'\n" + "yacc_badrule.py:25: Syntax error in rule 'statement'\n" + "yacc_badrule.py:30: Syntax error. Expected ':'\n" + "yacc_badrule.py:39: Syntax error. Expected ':'\n" )) def test_yacc_badtok(self): @@ -155,7 +154,7 @@ def test_yacc_dup(self): run_import("yacc_dup") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_dup.py:27: Function p_statement redefined. Previously defined on line 23\n" + "yacc_dup.py:24: Function p_statement redefined. Previously defined on line 20\n" "Token 'EQUALS' defined, but not used\n" "There is 1 unused token\n" "Generating LALR tables\n" @@ -167,7 +166,7 @@ def test_yacc_error1(self): except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_error1.py:61: p_error() requires 1 argument\n")) + "yacc_error1.py:58: p_error() requires 1 argument\n")) def test_yacc_error2(self): try: @@ -175,7 +174,7 @@ def test_yacc_error2(self): except ply.yacc.YaccError: result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_error2.py:61: p_error() requires 1 argument\n")) + "yacc_error2.py:58: p_error() requires 1 argument\n")) def test_yacc_error3(self): try: @@ -190,7 +189,7 @@ def test_yacc_error4(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_error4") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_error4.py:62: Illegal rule name 'error'. Already defined as a token\n" + "yacc_error4.py:59: Illegal rule name 'error'. Already defined as a token\n" )) @@ -237,20 +236,20 @@ def test_yacc_literal(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_literal") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_literal.py:36: Literal token '**' in rule 'expression' may only be a single character\n" + "yacc_literal.py:33: Literal token '**' in rule 'expression' may only be a single character\n" )) def test_yacc_misplaced(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_misplaced") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_misplaced.py:32: Misplaced '|'\n" + "yacc_misplaced.py:29: Misplaced '|'\n" )) def test_yacc_missing1(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_missing1") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_missing1.py:24: Symbol 'location' used, but not defined as a token or a rule\n" + "yacc_missing1.py:21: Symbol 'location' used, but not defined as a token or a rule\n" )) def test_yacc_nested(self): @@ -266,7 +265,7 @@ def test_yacc_nodoc(self): run_import("yacc_nodoc") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_nodoc.py:27: No documentation string specified in function 'p_statement_expr' (ignored)\n" + "yacc_nodoc.py:24: No documentation string specified in function 'p_statement_expr' (ignored)\n" "Generating LALR tables\n" )) @@ -282,7 +281,7 @@ def test_yacc_nop(self): run_import("yacc_nop") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_nop.py:27: Possible grammar rule 'statement_expr' defined without p_ prefix\n" + "yacc_nop.py:24: Possible grammar rule 'statement_expr' defined without p_ prefix\n" "Generating LALR tables\n" )) @@ -349,7 +348,7 @@ def test_yacc_term1(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_term1") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_term1.py:24: Illegal rule name 'NUMBER'. Already defined as a token\n" + "yacc_term1.py:21: Illegal rule name 'NUMBER'. Already defined as a token\n" )) def test_yacc_unicode_literals(self): @@ -363,7 +362,7 @@ def test_yacc_unused(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_unused") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_unused.py:62: Symbol 'COMMA' used, but not defined as a token or a rule\n" + "yacc_unused.py:59: Symbol 'COMMA' used, but not defined as a token or a rule\n" "Symbol 'COMMA' is unreachable\n" "Symbol 'exprlist' is unreachable\n" )) @@ -371,7 +370,7 @@ def test_yacc_unused_rule(self): run_import("yacc_unused_rule") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_unused_rule.py:62: Rule 'integer' defined, but not used\n" + "yacc_unused_rule.py:59: Rule 'integer' defined, but not used\n" "There is 1 unused rule\n" "Symbol 'integer' is unreachable\n" "Generating LALR tables\n" @@ -381,14 +380,14 @@ def test_yacc_uprec(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_uprec") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_uprec.py:37: Nothing known about the precedence of 'UMINUS'\n" + "yacc_uprec.py:34: Nothing known about the precedence of 'UMINUS'\n" )) def test_yacc_uprec2(self): self.assertRaises(ply.yacc.YaccError,run_import,"yacc_uprec2") result = sys.stderr.getvalue() self.assertTrue(check_expected(result, - "yacc_uprec2.py:37: Syntax error. Nothing follows %prec\n" + "yacc_uprec2.py:34: Syntax error. Nothing follows %prec\n" )) def test_yacc_prec1(self): diff --git a/test/yacc_badargs.py b/tests/yacc_badargs.py similarity index 98% rename from test/yacc_badargs.py rename to tests/yacc_badargs.py index 9a1d03f2..cd4b1e7c 100644 --- a/test/yacc_badargs.py +++ b/tests/yacc_badargs.py @@ -5,7 +5,7 @@ # ----------------------------------------------------------------------------- import sys sys.tracebacklimit = 0 -sys.path.insert(0,"..") + import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badid.py b/tests/yacc_badid.py similarity index 96% rename from test/yacc_badid.py rename to tests/yacc_badid.py index e4b9f5ee..f624aca1 100644 --- a/test/yacc_badid.py +++ b/tests/yacc_badid.py @@ -3,9 +3,6 @@ # # Attempt to define a rule with a bad-identifier name # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badprec.py b/tests/yacc_badprec.py similarity index 95% rename from test/yacc_badprec.py rename to tests/yacc_badprec.py index 3013bb62..95e9db20 100644 --- a/test/yacc_badprec.py +++ b/tests/yacc_badprec.py @@ -3,9 +3,6 @@ # # Bad precedence specifier # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badprec2.py b/tests/yacc_badprec2.py similarity index 95% rename from test/yacc_badprec2.py rename to tests/yacc_badprec2.py index 83093b42..c33303d7 100644 --- a/test/yacc_badprec2.py +++ b/tests/yacc_badprec2.py @@ -3,9 +3,6 @@ # # Bad precedence # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badprec3.py b/tests/yacc_badprec3.py similarity index 96% rename from test/yacc_badprec3.py rename to tests/yacc_badprec3.py index d925ecd5..e1ce3a62 100644 --- a/test/yacc_badprec3.py +++ b/tests/yacc_badprec3.py @@ -3,9 +3,6 @@ # # Bad precedence # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badrule.py b/tests/yacc_badrule.py similarity index 96% rename from test/yacc_badrule.py rename to tests/yacc_badrule.py index 92af6460..898a8c77 100644 --- a/test/yacc_badrule.py +++ b/tests/yacc_badrule.py @@ -3,9 +3,6 @@ # # Syntax problems in the rule strings # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_badtok.py b/tests/yacc_badtok.py similarity index 96% rename from test/yacc_badtok.py rename to tests/yacc_badtok.py index fc4afe19..567aadf0 100644 --- a/test/yacc_badtok.py +++ b/tests/yacc_badtok.py @@ -3,9 +3,6 @@ # # A grammar, but tokens is a bad datatype # ----------------------------------------------------------------------------- - -import sys -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc tokens = "Hello" diff --git a/test/yacc_dup.py b/tests/yacc_dup.py similarity index 95% rename from test/yacc_dup.py rename to tests/yacc_dup.py index 309ba329..94238a4e 100644 --- a/test/yacc_dup.py +++ b/tests/yacc_dup.py @@ -3,9 +3,6 @@ # # Duplicated rule name # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error1.py b/tests/yacc_error1.py similarity index 96% rename from test/yacc_error1.py rename to tests/yacc_error1.py index 10ac6a9c..39b9124c 100644 --- a/test/yacc_error1.py +++ b/tests/yacc_error1.py @@ -3,9 +3,6 @@ # # Bad p_error() function # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error2.py b/tests/yacc_error2.py similarity index 96% rename from test/yacc_error2.py rename to tests/yacc_error2.py index 75914180..2463ee9c 100644 --- a/test/yacc_error2.py +++ b/tests/yacc_error2.py @@ -3,9 +3,6 @@ # # Bad p_error() function # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error3.py b/tests/yacc_error3.py similarity index 95% rename from test/yacc_error3.py rename to tests/yacc_error3.py index 4604a48b..f1812534 100644 --- a/test/yacc_error3.py +++ b/tests/yacc_error3.py @@ -3,9 +3,6 @@ # # Bad p_error() function # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error4.py b/tests/yacc_error4.py similarity index 96% rename from test/yacc_error4.py rename to tests/yacc_error4.py index 9c550cd8..f6bef7ee 100644 --- a/test/yacc_error4.py +++ b/tests/yacc_error4.py @@ -3,9 +3,6 @@ # # Attempt to define a rule named 'error' # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error5.py b/tests/yacc_error5.py similarity index 97% rename from test/yacc_error5.py rename to tests/yacc_error5.py index 9eb0f857..5d4b6839 100644 --- a/test/yacc_error5.py +++ b/tests/yacc_error5.py @@ -3,9 +3,6 @@ # # Lineno and position tracking with error tokens # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error6.py b/tests/yacc_error6.py similarity index 96% rename from test/yacc_error6.py rename to tests/yacc_error6.py index 8d0ec85b..fde3c4db 100644 --- a/test/yacc_error6.py +++ b/tests/yacc_error6.py @@ -3,9 +3,6 @@ # # Panic mode recovery test # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_error7.py b/tests/yacc_error7.py similarity index 96% rename from test/yacc_error7.py rename to tests/yacc_error7.py index abdc8348..17cc4f1c 100644 --- a/test/yacc_error7.py +++ b/tests/yacc_error7.py @@ -3,9 +3,6 @@ # # Panic mode recovery test using deprecated functionality # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_inf.py b/tests/yacc_inf.py similarity index 95% rename from test/yacc_inf.py rename to tests/yacc_inf.py index efd3612a..f8b4c30d 100644 --- a/test/yacc_inf.py +++ b/tests/yacc_inf.py @@ -3,9 +3,6 @@ # # Infinite recursion # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_literal.py b/tests/yacc_literal.py similarity index 96% rename from test/yacc_literal.py rename to tests/yacc_literal.py index 0d628035..687d916a 100644 --- a/test/yacc_literal.py +++ b/tests/yacc_literal.py @@ -3,9 +3,6 @@ # # Grammar with bad literal characters # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_misplaced.py b/tests/yacc_misplaced.py similarity index 96% rename from test/yacc_misplaced.py rename to tests/yacc_misplaced.py index 9159b010..7cc75be3 100644 --- a/test/yacc_misplaced.py +++ b/tests/yacc_misplaced.py @@ -3,9 +3,6 @@ # # A misplaced | in grammar rules # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_missing1.py b/tests/yacc_missing1.py similarity index 96% rename from test/yacc_missing1.py rename to tests/yacc_missing1.py index d1b51059..81955be1 100644 --- a/test/yacc_missing1.py +++ b/tests/yacc_missing1.py @@ -3,9 +3,6 @@ # # Grammar with a missing rule # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_nested.py b/tests/yacc_nested.py similarity index 87% rename from test/yacc_nested.py rename to tests/yacc_nested.py index a3543a94..93ff4009 100644 --- a/test/yacc_nested.py +++ b/tests/yacc_nested.py @@ -1,6 +1,3 @@ -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") from ply import lex, yacc diff --git a/test/yacc_nodoc.py b/tests/yacc_nodoc.py similarity index 95% rename from test/yacc_nodoc.py rename to tests/yacc_nodoc.py index 0f61920a..a2f34ddc 100644 --- a/test/yacc_nodoc.py +++ b/tests/yacc_nodoc.py @@ -3,9 +3,6 @@ # # Rule with a missing doc-string # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_noerror.py b/tests/yacc_noerror.py similarity index 95% rename from test/yacc_noerror.py rename to tests/yacc_noerror.py index b38c7581..22627451 100644 --- a/test/yacc_noerror.py +++ b/tests/yacc_noerror.py @@ -3,9 +3,6 @@ # # No p_error() rule defined. # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_nop.py b/tests/yacc_nop.py similarity index 96% rename from test/yacc_nop.py rename to tests/yacc_nop.py index 789a9cfa..3ff17ac1 100644 --- a/test/yacc_nop.py +++ b/tests/yacc_nop.py @@ -3,9 +3,6 @@ # # Possible grammar rule defined without p_ prefix # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_notfunc.py b/tests/yacc_notfunc.py similarity index 95% rename from test/yacc_notfunc.py rename to tests/yacc_notfunc.py index 5093a744..c8bd123f 100644 --- a/test/yacc_notfunc.py +++ b/tests/yacc_notfunc.py @@ -3,9 +3,6 @@ # # p_rule not defined as a function # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_notok.py b/tests/yacc_notok.py similarity index 95% rename from test/yacc_notok.py rename to tests/yacc_notok.py index cff55a8d..6e271a02 100644 --- a/test/yacc_notok.py +++ b/tests/yacc_notok.py @@ -3,10 +3,6 @@ # # A grammar, but we forgot to import the tokens list # ----------------------------------------------------------------------------- - -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc # Parsing rules diff --git a/test/yacc_prec1.py b/tests/yacc_prec1.py similarity index 96% rename from test/yacc_prec1.py rename to tests/yacc_prec1.py index 99fcd903..d4fad6e0 100644 --- a/test/yacc_prec1.py +++ b/tests/yacc_prec1.py @@ -3,9 +3,6 @@ # # Tests case where precedence specifier doesn't match up to terminals # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_rr.py b/tests/yacc_rr.py similarity index 96% rename from test/yacc_rr.py rename to tests/yacc_rr.py index e7336c2f..de78a580 100644 --- a/test/yacc_rr.py +++ b/tests/yacc_rr.py @@ -3,9 +3,6 @@ # # A grammar with a reduce/reduce conflict # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_rr_unused.py b/tests/yacc_rr_unused.py similarity index 88% rename from test/yacc_rr_unused.py rename to tests/yacc_rr_unused.py index 1ca5f7e5..70a8c784 100644 --- a/test/yacc_rr_unused.py +++ b/tests/yacc_rr_unused.py @@ -4,9 +4,6 @@ # A grammar with reduce/reduce conflicts and a rule that never # gets reduced. # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc tokens = ('A', 'B', 'C') diff --git a/test/yacc_simple.py b/tests/yacc_simple.py similarity index 96% rename from test/yacc_simple.py rename to tests/yacc_simple.py index bd989f4d..5261838e 100644 --- a/test/yacc_simple.py +++ b/tests/yacc_simple.py @@ -3,9 +3,6 @@ # # A simple, properly specifier grammar # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_sr.py b/tests/yacc_sr.py similarity index 95% rename from test/yacc_sr.py rename to tests/yacc_sr.py index 69a1e9c7..0f15a50a 100644 --- a/test/yacc_sr.py +++ b/tests/yacc_sr.py @@ -3,9 +3,6 @@ # # A grammar with shift-reduce conflicts # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_term1.py b/tests/yacc_term1.py similarity index 96% rename from test/yacc_term1.py rename to tests/yacc_term1.py index eaa36e9d..1c1d8c20 100644 --- a/test/yacc_term1.py +++ b/tests/yacc_term1.py @@ -3,9 +3,6 @@ # # Terminal used on the left-hand-side # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_unicode_literals.py b/tests/yacc_unicode_literals.py similarity index 96% rename from test/yacc_unicode_literals.py rename to tests/yacc_unicode_literals.py index 5ae4f5b8..04f6cfd9 100644 --- a/test/yacc_unicode_literals.py +++ b/tests/yacc_unicode_literals.py @@ -5,9 +5,6 @@ # ----------------------------------------------------------------------------- from __future__ import unicode_literals -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_unused.py b/tests/yacc_unused.py similarity index 96% rename from test/yacc_unused.py rename to tests/yacc_unused.py index 55b677b1..7bc67499 100644 --- a/test/yacc_unused.py +++ b/tests/yacc_unused.py @@ -3,9 +3,6 @@ # # A grammar with an unused rule # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_unused_rule.py b/tests/yacc_unused_rule.py similarity index 96% rename from test/yacc_unused_rule.py rename to tests/yacc_unused_rule.py index 4868ef86..2e08d6d8 100644 --- a/test/yacc_unused_rule.py +++ b/tests/yacc_unused_rule.py @@ -3,9 +3,6 @@ # # Grammar with an unused rule # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_uprec.py b/tests/yacc_uprec.py similarity index 95% rename from test/yacc_uprec.py rename to tests/yacc_uprec.py index 569adb8f..f1735093 100644 --- a/test/yacc_uprec.py +++ b/tests/yacc_uprec.py @@ -3,9 +3,6 @@ # # A grammar with a bad %prec specifier # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens diff --git a/test/yacc_uprec2.py b/tests/yacc_uprec2.py similarity index 95% rename from test/yacc_uprec2.py rename to tests/yacc_uprec2.py index 73274bfb..85c0f2f3 100644 --- a/test/yacc_uprec2.py +++ b/tests/yacc_uprec2.py @@ -3,9 +3,6 @@ # # A grammar with a bad %prec specifier # ----------------------------------------------------------------------------- -import sys - -if ".." not in sys.path: sys.path.insert(0,"..") import ply.yacc as yacc from calclex import tokens