Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better test support #226

Merged
merged 28 commits into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
05ca99b
Testing osx travis builds
henryiii Sep 22, 2015
eedfd69
Updates for osx testing on Travis
henryiii Sep 22, 2015
4e6c3ce
Allow executing travis.sh
henryiii Sep 22, 2015
bb43678
Fix for installing python 3 on macos Travis, chdir correctly
henryiii Sep 22, 2015
543f0a5
Fix for missing 3 on pip for Py3 Mac
henryiii Sep 22, 2015
aedf673
Added Windows testing, standardized testing procedure
henryiii Sep 22, 2015
1b75109
Fixes for testing
henryiii Sep 22, 2015
e63a336
Fixed typo
henryiii Sep 23, 2015
4c82340
Better Appveyor tests
henryiii Sep 23, 2015
f098467
Changing to ogrisel example
henryiii Sep 23, 2015
214e7d9
Added more verbose testing, fewer builds
henryiii Sep 23, 2015
6a8c4bb
Typo fix
henryiii Sep 23, 2015
6266d88
Another Appveyor typo
henryiii Sep 23, 2015
c42b7d6
Fixed win32 download to correct pypi repo
henryiii Sep 23, 2015
64bacbf
Trying to get windows tests passing by skipping tests. Still work in
henryiii Sep 25, 2015
c98a07e
Implemented better test skipping
henryiii Sep 25, 2015
127b014
The tests that don't run on Appveyor are now labeled with windows skips.
henryiii Sep 25, 2015
6a68560
Appveyor new settings
henryiii Sep 25, 2015
6cdbfc0
Appveyor even better settings
henryiii Sep 25, 2015
eb57ede
Testing nosetests through powershell to remove odd error
henryiii Sep 25, 2015
35237ea
Forgot to install plumbum in appveyor, fixed
henryiii Sep 25, 2015
9b16349
Trying cmd for nosetests
henryiii Sep 25, 2015
73d7b61
Changing to py.test as default
henryiii Sep 25, 2015
e6f1475
Fix for missing py3 on Mac
henryiii Sep 25, 2015
4e849d1
Fix for windows only code breaking on Py3
henryiii Sep 25, 2015
e534c23
Trying to fix Py3 error on windows, dropped Py3.5 for now for Appveyor
henryiii Sep 25, 2015
cce5581
Merge branch 'master' into bugfixes
henryiii Oct 7, 2015
fb611db
Fixes after merge, Python 2.6 fix
henryiii Oct 7, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .ci/travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

if [[ "$(uname -s)" == 'Darwin' ]]; then
brew update
brew install python$PY3
pip$PY3 install pytest nose
pip$PY3 install paramiko
pip$PY3 install .
else
pip install paramiko || true
pip install .
fi

echo NoHostAuthenticationForLocalhost yes >> ~/.ssh/config
echo StrictHostKeyChecking no >> ~/.ssh/config
ssh-keygen -q -f ~/.ssh/id_rsa -N ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
36 changes: 17 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
sudo: required
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "nightly"
- "pypy"
matrix:
include:
- python: 2.6
- python: 2.7
- python: 3.2
- python: 3.3
- python: 3.4
- python: 3.5
- python: nightly
- python: pypy
- language: generic
os: osx
- language: generic
os: osx
env: PY3=3

before_script:
- "pip install paramiko || true"
- "echo NoHostAuthenticationForLocalhost yes >> ~/.ssh/config"
- "echo StrictHostKeyChecking no >> ~/.ssh/config"
- "ssh-keygen -q -f ~/.ssh/id_rsa -N ''"
- "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys"
- "python setup.py install"
- "cd tests"

script: nosetests -vv -d
install: .ci/travis.sh
script: cd tests && python$PY3 -m pytest

notifications:
email:
Expand Down
27 changes: 27 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
environment:
matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python34"
# Python 3.5 has to rebuild Crypto, because binaries are not available yet

install:
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%

# Check that we have the expected version and architecture for Python
- python --version
- python -c "import struct; print(struct.calcsize('P') * 8)"

# Upgrade to the latest version of pip to avoid it displaying warnings
# about it being out of date.
- pip install --disable-pip-version-check --user --upgrade pip

- pip install -r dev-requirements.txt
- pip install pypiwin32
- pip install .

build: false

test_script:
- ps: cd tests
- python -m pytest

2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
paramiko
pytest
35 changes: 35 additions & 0 deletions plumbum/_testtools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
import sys
import unittest
from plumbum import local
from plumbum.lib import IS_WIN32

def ensure_skipIf(unittest):
"""
This will ensure that unittest has skipIf. Call like::

import unittest
ensure_skipIf(unittest)
"""

if not hasattr(unittest, "skipIf"):
import logging
import functools
def skipIf(condition, reason):
def deco(func):
if not condition:
return func
else:
@functools.wraps(func)
def wrapper(*args, **kwargs):
logging.warn("skipping test: "+reason)
return wrapper
return deco
unittest.skipIf = skipIf

ensure_skipIf(unittest)
skipIf = unittest.skipIf

skip_on_windows = unittest.skipIf(IS_WIN32, "Does not work on Windows (yet)")
skip_without_chown = unittest.skipIf(not hasattr(os, "chown"), "os.chown not supported")
skip_without_tty = unittest.skipIf(not sys.stdin.isatty(), "Not a TTY")
22 changes: 0 additions & 22 deletions plumbum/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,6 @@ def get_method_function(m):
else:
from StringIO import StringIO

def ensure_skipIf(unittest):
"""
This will ensure that unittest has skipIf. Call like::

import unittest
ensure_skipIf(unittest)
"""

if not hasattr(unittest, "skipIf"):
import logging
import functools
def skipIf(condition, reason):
def deco(func):
if not condition:
return func
else:
@functools.wraps(func)
def wrapper(*args, **kwargs):
logging.warn("skipping test: "+reason)
return wrapper
return deco
unittest.skipIf = skipIf

@contextmanager
def captured_stdout(stdin = ""):
Expand Down
8 changes: 4 additions & 4 deletions plumbum/machines/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,16 @@ def list_processes(self):
"""
import csv
tasklist = local["tasklist"]
lines = tasklist("/V", "/FO", "CSV").encode("utf8").splitlines()
lines = tasklist("/V", "/FO", "CSV").splitlines()
rows = csv.reader(lines)
header = rows.next()
header = next(rows)
imgidx = header.index('Image Name')
pididx = header.index('PID')
statidx = header.index('Status')
useridx = header.index('User Name')
for row in rows:
yield ProcInfo(int(row[pididx]), row[useridx].decode("utf8"),
row[statidx].decode("utf8"), row[imgidx].decode("utf8"))
yield ProcInfo(int(row[pididx]), row[useridx],
row[statidx], row[imgidx])
else:
def list_processes(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[nosetests]
verbosity=2
detailed-errors=1
19 changes: 17 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@
import os

try:
from setuptools import setup
from setuptools import setup, Command
except ImportError:
from distutils.core import setup
from distutils.core import setup, Command

HERE = os.path.dirname(__file__)
exec(open(os.path.join(HERE, "plumbum", "version.py")).read())

class PyDocs(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import subprocess
import sys
os.chdir('docs')
errno = subprocess.call(['make', 'html'])
sys.exit(errno)

setup(name = "plumbum",
version = version_string, # @UndefinedVariable
description = "Plumbum: shell combinators library",
Expand All @@ -20,6 +33,8 @@
platforms = ["POSIX", "Windows"],
provides = ["plumbum"],
keywords = "path, local, remote, ssh, shell, pipe, popen, process, execution",
cmdclass = {
'docs':PyDocs},
# use_2to3 = False,
# zip_safe = True,
long_description = open(os.path.join(HERE, "README.rst"), "r").read(),
Expand Down
5 changes: 4 additions & 1 deletion tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This is for py.test -f with xdist plugin
[pytest]

# This is for py.test -f with xdist plugin
looponfailroots = . ../plumbum

addopts = -v --capture=sys
6 changes: 2 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

from plumbum import cli, local
from plumbum.cli.terminal import ask, choose, hexdump, Progress
from plumbum.lib import captured_stdout, ensure_skipIf

ensure_skipIf(unittest)
from plumbum.lib import captured_stdout

class TestApp(cli.Application):
@cli.switch(["a"])
Expand All @@ -28,7 +26,7 @@ def main(self, *args):
self.eggs = "lalala"
self.eggs = old
self.tailargs = args



class Geet(cli.Application):
Expand Down
Loading