Skip to content

Commit

Permalink
Provide basic support for #406 to be solved externally.
Browse files Browse the repository at this point in the history
Update to newest python (3.7) and packages (update some package versions).
Synchronize latest subrepo changes from "cucucumber/tag-expressions".
  • Loading branch information
jenisys committed Oct 13, 2018
1 parent 7900f3a commit 6c948d3
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 32 deletions.
4 changes: 2 additions & 2 deletions python/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
current_version = 1.0.2
files = setup.py cucumber_tag_expressions/__init__.py .bumpversion.cfg
current_version = 1.1.1
files = setup.py cucumber_tag_expressions/__init__.py .bumpversion.cfg pytest.ini
commit = False
tag = False
allow_dirty = True
Expand Down
2 changes: 2 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ __*/
.venv*/
.DS_Store
.coverage
.deps
.tested
Pipfile.lock
2 changes: 1 addition & 1 deletion python/.subrepo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cucumber/tag-expressions-python
cucumber/tag-expressions-python.git
12 changes: 4 additions & 8 deletions python/Pipfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"


[dev-packages]



[packages]

pytest = ">=3.0"
pytest-html = ">=1.16"
tox = ">=2.9.1"
pytest = ">=3.2"
pytest-html = ">=1.19"
tox = ">=2.9"
coverage = ">=4.2"
"enum34" = "*"
invoke = ">=0.21.0"
"path.py" = ">=10.1"
pathlib = "*"
"backports.shutil_which" = "*"
pycmd = "*"
six = ">=1.11.0"
15 changes: 14 additions & 1 deletion python/cucumber_tag_expressions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# -*- coding: UTF-8 -*-
"""
Python implementation of `cucumber tag-expressions`_.
Tag-expressions are used in cucumber, behave and other BDD frameworks
to select features, scenarios, etc. in `Gherkin`_ files.
Theses selected items are normally included in a test run.
.. seealso:: https://docs.cucumber.io/cucumber/tag-expressions/
.. _`cucumber tag-expressions`: https://docs.cucumber.io/cucumber/tag-expressions/
.. _`Gherkin`: https://docs.cucumber.io/gherkin/reference/
.. _`behave: Gherkin`: https://behave.readthedocs.io/en/latest/philosophy.html#the-gherkin-language
"""

from __future__ import absolute_import
from .parser import parse, TagExpressionParser, TagExpressionError

__version__ = "1.0.2"
__version__ = "1.1.1"
19 changes: 13 additions & 6 deletions python/cucumber_tag_expressions/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
assert "( a and ( b or not (c) ) )" == str(expression)
UNSUPPORTED:
* Support special tags w/ escaped-parens: @reqid\(10\)
* Support special tags w/ escaped-parens: ``@reqid\(10\)``
"""

from __future__ import absolute_import
Expand Down Expand Up @@ -108,7 +108,7 @@ class TagExpressionError(Exception):
# -----------------------------------------------------------------------------
class TagExpressionParser(object):
"""Parser class to parse boolean tag-expressions.
This class uses the `Shunting Yard algorithm`_ to parse the tag-expression.
This class uses the `Shunting Yard algorithm`_ to parse the tag-expression.
Boolean operations:
Expand All @@ -130,7 +130,7 @@ class TagExpressionParser(object):
expression = TagExpressionParser.parse(text11)
assert False == expression.evaluate(["foo"])
assert True == expression.evaluate(["other"])
# -- BINARY OPERATIONS:
text21 = "foo and bar" = "(foo and bar)"
expression = TagExpressionParser.parse(text21)
Expand All @@ -143,9 +143,9 @@ class TagExpressionParser(object):
assert True == expression.evaluate(["foo", "bar"])
assert True == expression.evaluate(["foo", "other"])
assert False == expression.evaluate([])
.. see::
* `Shunting Yard algorithm`_
* http://rosettacode.org/wiki/Parsing/Shunting-yard_algorithm
Expand All @@ -164,6 +164,12 @@ def select_token(cls, text):
"""
return cls.TOKEN_MAP.get(text, None)

@classmethod
def make_operand(cls, text):
"""Creates operand-object from parsed text."""
# -- EXTENSION-POINT: For #406 or similar.
return Literal(text)

@classmethod
def parse(cls, text):
"""Parse a textual tag-expression and return the expression (tree).
Expand Down Expand Up @@ -195,8 +201,9 @@ def ensure_expected_token_type(token_type):
for index, part in enumerate(parts):
token = cls.select_token(part)
if token is None:
# -- CASE OPERAND: Literal or ...
ensure_expected_token_type(TokenType.OPERAND)
expressions.append(Literal(part))
expressions.append(cls.make_operand(part))
expected_token_type = TokenType.OPERATOR
elif token.is_unary:
ensure_expected_token_type(TokenType.OPERAND)
Expand Down
5 changes: 4 additions & 1 deletion python/invoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ run:
echo: true
pty: true


clean_all:
extra_directories:
- .pytest_cache
- .hypothesis
6 changes: 3 additions & 3 deletions python/py.requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# PYTHON PACKAGE REQUIREMENTS FOR: For testing only
# ============================================================================

pytest >= 3.0
pytest-html >= 1.16
pytest >= 3.2
pytest-html >= 1.19

# -- DEVELOPMENT SUPPORT: Testing
tox >= 2.9.1
tox >= 2.9
coverage >= 4.2
5 changes: 5 additions & 0 deletions python/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
minversion = 3.2
testpaths = tests
python_files = test_*.py
addopts = --metadata PACKAGE_UNDER_TEST cucumber-tag-expressions
--metadata PACKAGE_VERSION 1.1.1
--html=build/testing/report.html --self-contained-html
--junit-xml=build/testing/report.xml

# -- BACKWARD COMPATIBILITY: pytest < 2.8
norecursedirs = .git .tox attic build dist py.requirements tmp* _WORKSPACE

27 changes: 18 additions & 9 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
SEE ALSO:
* https://packaging.python.org
REQUIRES:
* setuptools are installed
Expand Down Expand Up @@ -54,28 +54,36 @@ def find_packages_by_root_package(where):
# -----------------------------------------------------------------------------
setup(
name = "cucumber-tag-expressions",
version = "1.0.2",
version = "1.1.1",
author = "Jens Engel",
author_email = "jenisys@noreply.github.com",
url = "https://github.com/cucumber/tag-expressions-python",
download_url= "http://pypi.python.org/pypi/cucumber-tag-expressions",
description = "Provides tag-expression parser for cucumber/behave",
long_description = long_description,
keywords= "BDD, testing, behave, cucumber, tag-expressions",
license = "BSD",
keywords= "BDD, testing, cucumber, tag-expressions, behave",
license = "MIT",
packages = find_packages_by_root_package("cucumber_tag_expressions"),
include_package_data = True,

# -- REQUIREMENTS:
python_requires=">=2.7",
# XXX setup_requires = ["pytest-runner >= 3.0"],
install_requires=["enum34; python_version < '3.4'"],
tests_require=["pytest >= 3.0"],
install_requires=[
"enum34; python_version < '3.4'"
],
tests_require=[
"pytest >= 3.2",
"pytest-html >= 1.19.0",
],
extras_require={
# PREPARED: 'docs': ["sphinx>=1.5"],
'develop': [
"coverage", "pytest >= 3.0", "tox >= 2.9",
"invoke", "path.py",
"coverage",
"pytest >= 3.2",
"pytest-html >= 1.19.0",
"tox >= 2.9",
"invoke",
"path.py",
"pylint"
],
},
Expand All @@ -93,6 +101,7 @@ def find_packages_by_root_package(where):
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Testing",
Expand Down
3 changes: 2 additions & 1 deletion python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ changedir = {toxinidir}
commands=
pytest {posargs:tests}
deps=
pytest>=3.0
pytest>=3.2
pytest-html>=1.19
passenv =
PYTHONPATH = {toxinidir}

Expand Down

0 comments on commit 6c948d3

Please sign in to comment.