Merge branch 'master' into amalcomp

This commit is contained in:
Anthony Scopatz 2016-07-17 18:41:05 -04:00
commit b32492f39b
8 changed files with 64 additions and 46 deletions

View file

@ -1,9 +1,6 @@
version: 0.4.3.{build} version: 0.4.3.{build}
os: Windows Server 2012 R2 os: Windows Server 2012 R2
install: install:
- C:\Python35\Scripts\pip install ply pyreadline pytest pygments prompt_toolkit - C:\Python35\Scripts\pip install --upgrade -r requirements-tests.txt
build_script:
- C:\Python35\python setup.py install
test_script: test_script:
- C:\Python35\Scripts\py.test - C:\Python35\Scripts\py.test

7
.coveragerc Normal file
View file

@ -0,0 +1,7 @@
[run]
branch = true
omit =
tests/*
xonsh/__amalgam__.py
*/parser*_table.py
setup.py

View file

@ -4,8 +4,8 @@ python:
- 3.5 - 3.5
- "nightly" - "nightly"
install: install:
- pip install -r requirements-tests.txt - pip install --upgrade -r requirements-tests.txt
script: script:
- coverage run --source xonsh -m py.test -q - py.test --flake8 --cov=. --cov-report=term
after_success: after_success:
- codecov - codecov

2
conftest.py Normal file
View file

@ -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

View file

@ -1,6 +1,7 @@
ply ply
pytest pytest
pytest-flake8
pytest-cov
prompt-toolkit prompt-toolkit
pygments pygments
coverage
codecov codecov

15
setup.cfg Normal file
View file

@ -0,0 +1,15 @@
[pytest]
addopts = --flake8
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
__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

View file

@ -978,46 +978,42 @@ def test_argvquote(st, esc):
assert esc == obs assert esc == obs
_leaders = ('', 'not empty') @pytest.mark.parametrize('inp', ['no string here', ''])
_r = ('r', '') def test_partial_string_none(inp):
_b = ('b', '') assert check_for_partial_string(inp) == (None, None, None)
_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"
def test_partial_string(): @pytest.mark.parametrize('leaders', [
# single string at start (('', 0), ('not empty', 9)),
assert check_for_partial_string('no strings here') == (None, None, None) (('not empty', 9), ('', 0))
assert check_for_partial_string('') == (None, None, None) ])
for s, e in _startend.items(): @pytest.mark.parametrize('prefix', ['b', 'rb', 'r' ])
_test = s + inners + e @pytest.mark.parametrize('quote', ['"', '"""'])
for l in _leaders: def test_partial_string(leaders, prefix, quote):
for f in _leaders: (l, l_len), (f, f_len) = leaders
# single string s = prefix + quote
_res = check_for_partial_string(l + _test + f) t = s + 'test string' + quote
assert _res == (len(l), len(l) + len(_test), s) t_len = len(t)
# single partial # single string
_res = check_for_partial_string(l + f + s + inners) test_string = l + t + f
assert _res == (len(l+f), None, s) obs = check_for_partial_string(test_string)
for s2, e2 in _startend.items(): exp = l_len, l_len + t_len, s
_test2 = s2 + inners + e2 assert obs == exp
for l2 in _leaders: # single partial
for f2 in _leaders: test_string = l + f + s + 'test string'
# two strings obs = check_for_partial_string(test_string)
_res = check_for_partial_string(l + _test + f + l2 + _test2 + f2) exp = l_len + f_len, None, s
assert _res == (len(l+_test+f+l2), len(l+_test+f+l2+_test2), s2) assert obs == exp
# one string, one partial # two strings
_res = check_for_partial_string(l + _test + f + l2 + s2 + inners) test_string = l + t + f + l + t + f
assert _res == (len(l+_test+f+l2), None, s2) 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): def test_executables_in(xonsh_builtins):

View file

@ -984,7 +984,7 @@ def current_branch(pad=NotImplemented):
if isinstance(branch, subprocess.TimeoutExpired): if isinstance(branch, subprocess.TimeoutExpired):
branch = '<branch-timeout>' branch = '<branch-timeout>'
_first_branch_timeout_message() _first_branch_timeout_message()
return branch return branch or None
def git_dirty_working_directory(cwd=None, include_untracked=False): def git_dirty_working_directory(cwd=None, include_untracked=False):