Skip to content

Commit 5c5e33b

Browse files
committed
Merge pull request #14 from graingert/test-using-tox
test using tox
2 parents 4a3d3a1 + e109c81 commit 5c5e33b

File tree

7 files changed

+117
-70
lines changed

7 files changed

+117
-70
lines changed

.gitignore

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,85 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
13
*.py[cod]
4+
*$py.class
25

36
# C extensions
47
*.so
58

6-
# Packages
7-
*.egg
8-
*.egg-info
9-
dist
10-
build
11-
eggs
12-
parts
13-
bin
14-
var
15-
sdist
16-
develop-eggs
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
1724
.installed.cfg
18-
lib
19-
lib64
20-
__pycache__
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
2132

2233
# Installer logs
2334
pip-log.txt
35+
pip-delete-this-directory.txt
2436

2537
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
2640
.coverage
27-
.tox
41+
.coverage.*
42+
.cache
2843
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
2947

3048
# Translations
3149
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
56+
# Flask instance folder
57+
instance/
58+
59+
# Scrapy stuff:
60+
.scrapy
61+
62+
# Sphinx documentation
63+
docs/_build/
64+
65+
# PyBuilder
66+
target/
67+
68+
# IPython Notebook
69+
.ipynb_checkpoints
70+
71+
# pyenv
72+
.python-version
73+
74+
# celery beat schedule file
75+
celerybeat-schedule
76+
77+
# dotenv
78+
.env
79+
80+
# virtualenv
81+
venv/
82+
ENV/
3283

33-
# Mr Developer
34-
.mr.developer.cfg
35-
.project
36-
.pydevproject
84+
# Spyder project settings
85+
.spyderproject

.travis.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
language: python
2-
python:
3-
- "2.5"
4-
- "2.6"
5-
- "2.7"
6-
- "pypy"
7-
- "3.3"
8-
- "3.4"
2+
python: 3.5
3+
env:
4+
- TOX_ENV=py26
5+
- TOX_ENV=py27
6+
- TOX_ENV=pypy
7+
- TOX_ENV=py34
8+
- TOX_ENV=py35
9+
- TOX_ENV=lint
910
install:
1011
- sudo apt-get install clamav-daemon clamav-freshclam clamav-unofficial-sigs
1112
- sudo freshclam --verbose
1213
- sudo service clamav-daemon start
13-
- pip install .
14-
script: python setup.py nosetests
15-
matrix:
16-
allow_failures:
17-
- python: "2.5"
14+
- pip install tox
15+
script: tox -e $TOX_ENV

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To scan a file::
3535

3636
To scan a stream::
3737

38-
>>> from six import BytesIO
38+
>>> from io import BytesIO
3939
>>> cd.instream(BytesIO(clamd.EICAR))
4040
{'stream': ('FOUND', 'Eicar-Test-Signature')}
4141

setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
classifiers = [
2424
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
2525
],
26-
tests_require = (
27-
"nose==1.3.3",
28-
"six==1.7.3",
29-
),
30-
test_suite='nose.collector',
3126
zip_safe=True,
3227
include_package_data=False,
3328
)

src/clamd/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import base64
1919

2020
scan_response = re.compile(r"^(?P<path>.*): ((?P<virus>.+) )?(?P<status>(FOUND|OK|ERROR))$")
21-
EICAR = base64.b64decode(b'WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5E' \
22-
b'QVJELUFOVElWSVJVUy1URVNU\nLUZJTEUhJEgrSCo=\n')
21+
EICAR = base64.b64decode(
22+
b'WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5E'
23+
b'QVJELUFOVElWSVJVUy1URVNU\nLUZJTEUhJEgrSCo=\n'
24+
)
2325

2426

2527
class ClamdError(Exception):

src/tests/test_api.py

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# -*- coding: utf-8 -*-
33
from __future__ import unicode_literals
44
import clamd
5-
from six import BytesIO
5+
from io import BytesIO
66
from contextlib import contextmanager
77
import tempfile
88
import shutil
99
import os
1010
import stat
1111

12-
from nose.tools import ok_, eq_, assert_true, raises
12+
import pytest
1313

1414
mine = (stat.S_IREAD | stat.S_IWRITE)
1515
other = stat.S_IROTH
@@ -26,38 +26,37 @@ def mkdtemp(*args, **kwargs):
2626

2727

2828
class TestUnixSocket(object):
29-
def __init__(self):
30-
self.kwargs = {}
29+
kwargs = {}
3130

3231
def setup(self):
3332
self.cd = clamd.ClamdUnixSocket(**self.kwargs)
3433

3534
def test_ping(self):
36-
assert_true(self.cd.ping())
35+
assert self.cd.ping()
3736

3837
def test_version(self):
39-
ok_(self.cd.version().startswith("ClamAV"))
38+
assert self.cd.version().startswith("ClamAV")
4039

4140
def test_reload(self):
42-
eq_(self.cd.reload(), 'RELOADING')
41+
assert self.cd.reload() == 'RELOADING'
4342

4443
def test_scan(self):
4544
with tempfile.NamedTemporaryFile('wb', prefix="python-clamd") as f:
4645
f.write(clamd.EICAR)
4746
f.flush()
4847
os.fchmod(f.fileno(), (mine | other))
49-
eq_(self.cd.scan(f.name),
50-
{f.name: ('FOUND', 'Eicar-Test-Signature')}
51-
)
48+
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
49+
50+
assert self.cd.scan(f.name) == expected
5251

5352
def test_unicode_scan(self):
5453
with tempfile.NamedTemporaryFile('wb', prefix=u"python-clamdλ") as f:
5554
f.write(clamd.EICAR)
5655
f.flush()
5756
os.fchmod(f.fileno(), (mine | other))
58-
eq_(self.cd.scan(f.name),
59-
{f.name: ('FOUND', 'Eicar-Test-Signature')}
60-
)
57+
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
58+
59+
assert self.cd.scan(f.name) == expected
6160

6261
def test_multiscan(self):
6362
expected = {}
@@ -69,31 +68,20 @@ def test_multiscan(self):
6968
expected[f.name] = ('FOUND', 'Eicar-Test-Signature')
7069
os.chmod(d, (mine | other | execute))
7170

72-
eq_(self.cd.multiscan(d), expected)
71+
assert self.cd.multiscan(d) == expected
7372

7473
def test_instream(self):
75-
eq_(
76-
self.cd.instream(BytesIO(clamd.EICAR)),
77-
{'stream': ('FOUND', 'Eicar-Test-Signature')}
78-
)
74+
expected = {'stream': ('FOUND', 'Eicar-Test-Signature')}
75+
assert self.cd.instream(BytesIO(clamd.EICAR)) == expected
7976

8077
def test_insteam_success(self):
81-
eq_(
82-
self.cd.instream(BytesIO(b"foo")),
83-
{'stream': ('OK', None)}
84-
)
78+
assert self.cd.instream(BytesIO(b"foo")) == {'stream': ('OK', None)}
8579

8680

8781
class TestUnixSocketTimeout(TestUnixSocket):
88-
def __init__(self):
89-
self.kwargs = {"timeout": 20}
82+
kwargs = {"timeout": 20}
9083

9184

92-
@raises(clamd.ConnectionError)
9385
def test_cannot_connect():
94-
clamd.ClamdUnixSocket(path="/tmp/404").ping()
95-
96-
97-
# class TestNetworkSocket(TestUnixSocket):
98-
# def setup(self):
99-
# self.cd = clamd.ClamdNetworkSocket()
86+
with pytest.raises(clamd.ConnectionError):
87+
clamd.ClamdUnixSocket(path="/tmp/404").ping()

tox.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tox]
2+
envlist = py{26,27,33,34,35}, lint
3+
4+
[testenv]
5+
commands = py.test {posargs}
6+
deps =
7+
pytest==2.8.2
8+
9+
[testenv:lint]
10+
deps =
11+
flake8==2.4.0
12+
commands=flake8 src
13+
14+
[flake8]
15+
max-line-length = 117

0 commit comments

Comments
 (0)