From 74de1591c55fbb53dafae9c8feef9b0cb2dc152f Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 09:34:01 +0200 Subject: [PATCH 01/14] run flake8 and coverage inside pytest and on travis --- .travis.yml | 2 +- requirements-tests.txt | 3 ++- setup.cfg | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index a676d4473..bf762c624 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,6 @@ python: install: - pip install -r requirements-tests.txt script: - - coverage run --source xonsh -m py.test -q + - py.test --flake8 --cov=. --cov-report=term -q after_success: - codecov diff --git a/requirements-tests.txt b/requirements-tests.txt index db2a85c2b..fc513fe37 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,6 +1,7 @@ ply pytest +pytest-flake8 +pytest-cov prompt-toolkit pygments -coverage codecov diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..aa2d2dc5b --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[pytest] +addopts = --flake8 +flake8-max-line-length = 150 +flake8-ignore = + # Temporary until we fix all the errors + *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 + __amalgam__.py ALL + # test files should be PEP8 but a ton of errors for now + test_*.py ALL + # we don't care about sphinx autogenerated files + docs/*.py ALL + # we don't care about ply files? + ply/*.py ALL + # these run VERY slowly and give tons of errors + parser*_table.py ALL From d931503fddc1cfd68ed34187499557e8409d5c2e Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 09:34:13 +0200 Subject: [PATCH 02/14] improve coverage reports --- .coveragerc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..aa4806b0d --- /dev/null +++ b/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = true +omit = + tests/* + xonsh/__amalgam__.py + */parser*_table.py + setup.py From d01daa192823f91e486b17c5f25f65381450f478 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 09:37:09 +0200 Subject: [PATCH 03/14] ignore more errors --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index aa2d2dc5b..ccc813edd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ addopts = --flake8 flake8-max-line-length = 150 flake8-ignore = # Temporary until we fix all the errors - *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 + *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 F811 F841 __amalgam__.py ALL # test files should be PEP8 but a ton of errors for now test_*.py ALL From f39e09d7bd1527355ceaf3ac532f1f7925409bc6 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 09:40:18 +0200 Subject: [PATCH 04/14] upgrade dependencies --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf762c624..0f2fff71f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ python: - 3.5 - "nightly" install: - - pip install -r requirements-tests.txt + - pip install --upgrade -r requirements-tests.txt script: - py.test --flake8 --cov=. --cov-report=term -q after_success: From 0501f2d0355520d12189f29e91c64d538a958fdc Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 11:40:07 +0200 Subject: [PATCH 05/14] this might help --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f2fff71f..99f86b03c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,12 @@ python: - 3.4 - 3.5 - "nightly" +env: + - XONSH_DEBUG=1 install: - pip install --upgrade -r requirements-tests.txt script: - - py.test --flake8 --cov=. --cov-report=term -q + - python setup.py develop + - XONSH_DEBUG=1 py.test --flake8 --cov=. --cov-report=term after_success: - codecov From 6f357e4b0a9b1bdb059508c5ba0b7dac47782448 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 11:42:59 +0200 Subject: [PATCH 06/14] remove redundant variable --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 99f86b03c..ff2a12a3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,6 @@ install: - pip install --upgrade -r requirements-tests.txt script: - python setup.py develop - - XONSH_DEBUG=1 py.test --flake8 --cov=. --cov-report=term + - py.test --flake8 --cov=. --cov-report=term after_success: - codecov From 426ecdaceed5995ed5c48be4ec4153a046d121da Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 11:44:55 +0200 Subject: [PATCH 07/14] remove remaining errors --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ccc813edd..72d117f16 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ addopts = --flake8 flake8-max-line-length = 150 flake8-ignore = # Temporary until we fix all the errors - *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 F811 F841 + *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 F811 F841 F821 F402 __amalgam__.py ALL # test files should be PEP8 but a ton of errors for now test_*.py ALL From c399b10b0fc9b9a83752532477676ef3086f62ab Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 13:46:06 +0200 Subject: [PATCH 08/14] fix the need for develop and avoiding amalgamate --- .travis.yml | 3 --- conftest.py | 0 2 files changed, 3 deletions(-) create mode 100644 conftest.py diff --git a/.travis.yml b/.travis.yml index ff2a12a3a..7f1fcf7d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,9 @@ python: - 3.4 - 3.5 - "nightly" -env: - - XONSH_DEBUG=1 install: - pip install --upgrade -r requirements-tests.txt script: - - python setup.py develop - py.test --flake8 --cov=. --cov-report=term after_success: - codecov diff --git a/conftest.py b/conftest.py new file mode 100644 index 000000000..e69de29bb From 18a4d729511899d01d0d1ba1101eba5f03046b03 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 18:09:06 +0200 Subject: [PATCH 09/14] use requirements and don't install no need to install now that we have the empty conftest.py --- .appveyor.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f53ab5b41..7603ca059 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,9 +1,6 @@ version: 0.4.3.{build} os: Windows Server 2012 R2 install: -- C:\Python35\Scripts\pip install ply pyreadline pytest pygments prompt_toolkit -build_script: -- C:\Python35\python setup.py install +- C:\Python35\Scripts\pip install -r requirements-tests.txt test_script: - C:\Python35\Scripts\py.test - From 1fd8f4ade4f0e8a5ecadbb131b2c139cd239df82 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Fri, 15 Jul 2016 18:09:41 +0200 Subject: [PATCH 10/14] forgot to always try to upgrade everything, else we run into very old packages --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 7603ca059..6ab62acda 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,6 @@ version: 0.4.3.{build} os: Windows Server 2012 R2 install: -- C:\Python35\Scripts\pip install -r requirements-tests.txt +- C:\Python35\Scripts\pip install --upgrade -r requirements-tests.txt test_script: - C:\Python35\Scripts\py.test From ae9f52defdf6b9dba53d607b5377cd5f7426f2d9 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Fri, 15 Jul 2016 19:29:20 -0400 Subject: [PATCH 11/14] branch space fix --- xonsh/environ.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xonsh/environ.py b/xonsh/environ.py index 80caebb73..5c4c69402 100644 --- a/xonsh/environ.py +++ b/xonsh/environ.py @@ -984,7 +984,7 @@ def current_branch(pad=NotImplemented): if isinstance(branch, subprocess.TimeoutExpired): branch = '' _first_branch_timeout_message() - return branch + return branch or None def git_dirty_working_directory(cwd=None, include_untracked=False): From e182a7332dd0b4ec09c60d58567572a4bb1fd501 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Sun, 17 Jul 2016 01:21:11 +0200 Subject: [PATCH 12/14] add comment on conftest.py to why it exists --- conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conftest.py b/conftest.py index e69de29bb..0b7a75eae 100644 --- a/conftest.py +++ b/conftest.py @@ -0,0 +1,2 @@ +# empty file to trick py.test into adding the root folder to sys.path +# see https://github.com/pytest-dev/pytest/issues/911 for more info From 723ede50916d044f02bfa719c35e1f5e7d4efb64 Mon Sep 17 00:00:00 2001 From: Leonardo Santagada Date: Sun, 17 Jul 2016 14:09:11 +0200 Subject: [PATCH 13/14] need to allow even longer lines to not break the build now. --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 72d117f16..752b61a3c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [pytest] addopts = --flake8 -flake8-max-line-length = 150 +flake8-max-line-length = 180 flake8-ignore = # Temporary until we fix all the errors - *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 F811 F841 F821 F402 + *.py E301 E302 E303 W391 E402 E127 E128 E201 E731 E701 E271 E265 E266 E225 E202 E502 E231 E228 E227 E203 E122 E251 W291 E124 E261 E125 E111 E222 E272 F401 F811 F841 F821 F402 __amalgam__.py ALL # test files should be PEP8 but a ton of errors for now test_*.py ALL From 245b5f712003b63a23b74ca31f7ac9a8236a8f5b Mon Sep 17 00:00:00 2001 From: laerus Date: Mon, 18 Jul 2016 00:35:50 +0300 Subject: [PATCH 14/14] test_partial_string ref --- tests/test_tools.py | 72 +++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/tests/test_tools.py b/tests/test_tools.py index e9fe6a6c0..22538a44a 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -978,46 +978,42 @@ def test_argvquote(st, esc): assert esc == obs -_leaders = ('', 'not empty') -_r = ('r', '') -_b = ('b', '') -_u = ('u', '') -_chars = set(i+j+k for i in _r for j in _b for k in _u) -_chars |= set(i+j+k for i in _r for j in _u for k in _b) -_chars |= set(i+j+k for i in _b for j in _u for k in _r) -_chars |= set(i+j+k for i in _b for j in _r for k in _u) -_chars |= set(i+j+k for i in _u for j in _r for k in _b) -_chars |= set(i+j+k for i in _u for j in _b for k in _r) -_squote = ('"""', '"', "'''", "'") -_startend = {c+s: s for c in _chars for s in _squote} - -inners = "this is a string" +@pytest.mark.parametrize('inp', ['no string here', '']) +def test_partial_string_none(inp): + assert check_for_partial_string(inp) == (None, None, None) -def test_partial_string(): - # single string at start - assert check_for_partial_string('no strings here') == (None, None, None) - assert check_for_partial_string('') == (None, None, None) - for s, e in _startend.items(): - _test = s + inners + e - for l in _leaders: - for f in _leaders: - # single string - _res = check_for_partial_string(l + _test + f) - assert _res == (len(l), len(l) + len(_test), s) - # single partial - _res = check_for_partial_string(l + f + s + inners) - assert _res == (len(l+f), None, s) - for s2, e2 in _startend.items(): - _test2 = s2 + inners + e2 - for l2 in _leaders: - for f2 in _leaders: - # two strings - _res = check_for_partial_string(l + _test + f + l2 + _test2 + f2) - assert _res == (len(l+_test+f+l2), len(l+_test+f+l2+_test2), s2) - # one string, one partial - _res = check_for_partial_string(l + _test + f + l2 + s2 + inners) - assert _res == (len(l+_test+f+l2), None, s2) +@pytest.mark.parametrize('leaders', [ + (('', 0), ('not empty', 9)), + (('not empty', 9), ('', 0)) +]) +@pytest.mark.parametrize('prefix', ['b', 'rb', 'r' ]) +@pytest.mark.parametrize('quote', ['"', '"""']) +def test_partial_string(leaders, prefix, quote): + (l, l_len), (f, f_len) = leaders + s = prefix + quote + t = s + 'test string' + quote + t_len = len(t) + # single string + test_string = l + t + f + obs = check_for_partial_string(test_string) + exp = l_len, l_len + t_len, s + assert obs == exp + # single partial + test_string = l + f + s + 'test string' + obs = check_for_partial_string(test_string) + exp = l_len + f_len, None, s + assert obs == exp + # two strings + test_string = l + t + f + l + t + f + obs = check_for_partial_string(test_string) + exp = (l_len + t_len + f_len + l_len), (l_len + t_len + f_len + l_len + t_len), s + assert obs == exp + # one string, one partial + test_string = l + t + f + l + s + 'test string' + obs = check_for_partial_string(test_string) + exp = l_len + t_len + f_len + l_len , None, s + assert obs == exp def test_executables_in(xonsh_builtins):