Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge 5677ecb into 0802e4f
Browse files Browse the repository at this point in the history
  • Loading branch information
Buck Evan committed Sep 3, 2015
2 parents 0802e4f + 5677ecb commit ab99e67
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
make venv
. venv-venv_update/bin/activate
1 change: 1 addition & 0 deletions .deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deactivate
4 changes: 4 additions & 0 deletions .pep8
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[pep8]
max-line-length=131
exclude=.tox,*.tmp,tmp/

[flake8]
max-line-length=131
exclude=.tox,*.tmp,tmp/
Expand Down
36 changes: 24 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 15b678e9c67c42765c3d579e40672a332f4366d7
sha: 616c1ebd1898c91de9a0548866a59cbd9f4547f6
hooks:
- id: trailing-whitespace
files: \.(md|py|txt|sh)$
- id: end-of-file-fixer
files: \.(md|py|txt|sh)$
- id: autopep8-wrapper
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
files: \.py$
- id: name-tests-test
files: tests/.+\.py$
exclude: tests/testing.*\.py$
- id: detect-private-key
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: flake8
files: \.py$
- repo: git://github.com/bukzor/pre-commit-system-hook.git
sha: 64a3e3f0d11f74ccd0498ea3149c8e177dd9989c
- repo: git://github.com/asottile/reorder_python_imports
sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10
hooks:
- id: reorder-python-imports
args:
- --add-import
- from __future__ import absolute_import
- --add-import
- from __future__ import print_function
- --add-import
- from __future__ import unicode_literals
- repo: local
hooks:
- id: system
name: PyLint
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ env:
# putting this ahead of the `python` directive
# means we start all lints before any tests
- TOXENV=lint
- TOXENV=test
- TOXENV=python
python:
# in order of most-valuable tests first
- "3.4"
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ all: lint test

.PHONY: lint
lint:
pre-commit run --all
pre-commit run --all-files

.PHONY: test tests
test tests:
./.travis/test.sh $(ARGS)
./test $(ARGS)

.PHONY: tox
tox:
tox -e lint,test

.PHONY: venv
venv:
tox -ve venv
# see: https://bitbucket.org/ned/coveragepy/issue/340/keyerror-subpy#comment-13671053
rm -rf venv-venv_update/local/

.PHONY: clean
clean:
rm -rf .tox
Expand Down
3 changes: 3 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ max-line-length=131
[TYPECHECK]
ignored-classes=pytest,LocalPath

[SIMILARITIES]
ignore-imports=yes

[DESIGN]
min-public-methods=0

Expand Down
4 changes: 3 additions & 1 deletion requirements.d/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
-e .
-r test.txt
-r _lint.txt
tox

# <2 -- https://bitbucket.org/hpk42/tox/issue/246
tox>=1.9,<2
2 changes: 1 addition & 1 deletion requirements.d/prod.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# minimal set of packasges for end-users
# minimal set of packages for end-users
virtualenv<2
2 changes: 1 addition & 1 deletion requirements.d/travis.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# minimal set of packages for travis to run our test suites
tox
tox>=1.9,<2
coverage
coveralls
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from setuptools import find_packages
from setuptools import setup

Expand All @@ -9,7 +11,7 @@ def main():
setup(
name='venv-update',
version='0.1.2dev0',
description="Quickly and exactly synchronize a virtualenv with a requirements.txt",
description='Quickly and exactly synchronize a virtualenv with a requirements.txt',
url='https://github.com/Yelp/venv-update',
author='Buck Golemon',
author_email='buck@yelp.com',
Expand Down
4 changes: 2 additions & 2 deletions .travis/test.sh → test
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export PROJECT=venv_update
NCPU=$(getconf _NPROCESSORS_CONF)

if python -c 'import platform; exit(not(platform.python_implementation() == "PyPy"))'; then
# coverage under pypy takes too dang long:
# https://bitbucket.org/pypy/pypy/issue/1871/10x-slower-than-cpython-under-coverage#comment-14404182
PYPY=true
else
PYPY=false
fi

if $PYPY; then
# coverage under pypy takes too dang long:
# https://bitbucket.org/pypy/pypy/issue/1871/10x-slower-than-cpython-under-coverage#comment-14404182
# Having issues with memory, let's try reducing CPUs by half
py.test -n $((NCPU / 3)) \
"$@" $TOP/tests $SITEPACKAGES/${PROJECT}.py
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import pytest


@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(scope='session', autouse=True)
def no_pip_environment_vars():
import os
for var in dict(os.environ):
if var.startswith('PIP_'):
del os.environ[var]


@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(scope='session', autouse=True)
def no_pythonpath_environment_var():
import os
for var in dict(os.environ):
Expand Down
23 changes: 15 additions & 8 deletions tests/functional/conflict_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from subprocess import CalledProcessError

import pytest

import testing as T


Expand All @@ -25,12 +25,15 @@ def test_conflicting_reqs(tmpdir):
assert err == ''

out = T.uncolor(out)
assert '''
assert (
'''
Cleaning up...
Error: version conflict: mccabe 0.2 <-> mccabe>=0.2.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: version conflict: mccabe 0.2 (virtualenv_run/lib/python2.7/site-packages)'''
''' <-> mccabe>=0.2.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Something went wrong! Sending 'virtualenv_run' back in time, so make knows it's invalid.
''' in out
'''
) in out


def test_multiple_issues(tmpdir):
Expand All @@ -56,11 +59,15 @@ def test_multiple_issues(tmpdir):
assert err == ''

out = T.uncolor(out)
assert '''
assert (
'''
Cleaning up...
Error: version conflict: mccabe 0.2 <-> mccabe>=0.2.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: version conflict: pep8 1.0 <-> pep8>=1.5.7 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: version conflict: mccabe 0.2 (virtualenv_run/lib/python2.7/site-packages)'''
''' <-> mccabe>=0.2.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: version conflict: pep8 1.0 (virtualenv_run/lib/python2.7/site-packages) '''
'''<-> pep8>=1.5.7 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Error: unmet dependency: pyflakes>=0.8.1 (from flake8==2.2.5 (from -r requirements.txt (line 3)))
Something went wrong! Sending 'virtualenv_run' back in time, so make knows it's invalid.
''' in out
'''
) in out
4 changes: 3 additions & 1 deletion tests/functional/get_installed_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from testing import run, venv_update_script
from testing import run
from testing import venv_update_script


def get_installed():
Expand Down
8 changes: 7 additions & 1 deletion tests/functional/help_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from testing import strip_coverage_warnings, venv_update
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from testing import strip_coverage_warnings
from testing import venv_update

from venv_update import __doc__ as HELP_OUTPUT


Expand Down
4 changes: 3 additions & 1 deletion tests/functional/install_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

from testing import run, venv_update_script
from testing import run
from testing import venv_update_script


def test_pip_install_flake8(tmpdir):
Expand Down
9 changes: 8 additions & 1 deletion tests/functional/relocation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from __future__ import print_function
from __future__ import unicode_literals

from testing import Path, requirements, run, venv_update
from testing import Path
from testing import requirements
from testing import run
from testing import venv_update


def test_relocatable(tmpdir):
Expand Down Expand Up @@ -41,16 +44,20 @@ def test_python_versions(tmpdir):


def test_virtualenv_moved(tmpdir):
"""if you move the virtualenv and venv-update again, the old will be blown away, and things will work"""
original_path = 'original'
new_path = 'new_dir'

tmpdir.mkdir(original_path).chdir()
requirements("flake8==2.4.0\n")
Path('run.py').write("")
venv_update()
run('virtualenv_run/bin/flake8', 'run.py')
run('virtualenv_run/bin/python', 'virtualenv_run/bin/flake8', 'run.py')

tmpdir.chdir()
Path(original_path).rename(new_path)
tmpdir.join(new_path).chdir()
venv_update()
run('virtualenv_run/bin/flake8', 'run.py')
run('virtualenv_run/bin/python', 'virtualenv_run/bin/flake8', 'run.py')
28 changes: 15 additions & 13 deletions tests/functional/simple_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import re
from py._path.local import LocalPath as Path
import pytest

from testing import (
TOP,
requirements,
run,
strip_coverage_warnings,
uncolor,
venv_update,
venv_update_symlink_pwd,
)

import re
from sys import version_info

import pytest
from py._path.local import LocalPath as Path
from testing import requirements
from testing import run
from testing import strip_coverage_warnings
from testing import TOP
from testing import uncolor
from testing import venv_update
from testing import venv_update_symlink_pwd
PY33 = (version_info >= (3, 3))


Expand Down Expand Up @@ -47,7 +46,9 @@ def install_twice(tmpdir, between):
simplejson==3.6.5
pyyaml==3.11
pylint==1.4.0
logilab-common==0.63.2
astroid<1.3.3
py==1.4.26
pytest==2.6.4
unittest2==0.8.0
six<=1.8.0
Expand Down Expand Up @@ -163,6 +164,7 @@ def test_arguments_version(tmpdir):

assert excinfo.value.returncode == 1
out, err = excinfo.value.result
err = strip_coverage_warnings(err)
lasterr = err.rsplit('\n', 2)[-2]
assert lasterr.startswith('virtualenv executable not found: /'), err
assert lasterr.endswith('/virtualenv_run/bin/python'), err
Expand Down
15 changes: 12 additions & 3 deletions tests/functional/stage2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
We need to test "stage 2" independently for coverage measurements.
The coverage tool loses track of it because it's run via os.exec().
"""
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import pytest
from testing import requirements
from testing import run
from testing import strip_coverage_warnings
from testing import TOP
from testing import uncolor

from testing import TOP, requirements, run, uncolor
import venv_update


Expand All @@ -31,7 +37,7 @@ def test_trivial(tmpdir):
run(
'myvenv/bin/pip',
'install',
'-r', (TOP/'requirements.d/coverage.txt').strpath
'-r', (TOP / 'requirements.d/coverage.txt').strpath
)

stage2('myvenv/bin/python', tmpdir)
Expand All @@ -48,9 +54,11 @@ def test_error_with_wrong_python(tmpdir):

assert excinfo.value.returncode == 1
out, err = excinfo.value.result
lasterr = err.rsplit('\n', 2)[-2]

err = strip_coverage_warnings(err)
lasterr = err.rsplit('\n', 2)[-2]
assert lasterr == 'AssertionError: Executable not in venv: %s != %s/myvenv/bin/python' % (executable, tmpdir.strpath)

assert out == ''


Expand All @@ -70,6 +78,7 @@ def test_touch_on_error(tmpdir):
assert excinfo.value.returncode == 1
out, err = excinfo.value.result

err = strip_coverage_warnings(err)
lasterr = err.rsplit('\n', 2)[-2]
assert lasterr == 'AssertionError: Executable not in venv: %s != %s/myvenv/bin/python' % (executable, tmpdir.strpath)

Expand Down

0 comments on commit ab99e67

Please sign in to comment.