Skip to content

Commit ea01d1c

Browse files
committed
use tox
1 parent 6cce2c8 commit ea01d1c

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

setup.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#!/usr/bin/env python
2+
import sys
3+
14
from setuptools import setup
5+
from setuptools.command.test import test as TestCommand
26

37

48
def readme():
@@ -11,6 +15,26 @@ def license_text():
1115
return f.read()
1216

1317

18+
class Tox(TestCommand):
19+
def initialize_options(self):
20+
TestCommand.initialize_options(self)
21+
self.tox_args = None
22+
23+
def finalize_options(self):
24+
TestCommand.finalize_options(self)
25+
self.test_args = []
26+
self.test_suite = True
27+
28+
def run_tests(self):
29+
import tox
30+
import shlex
31+
args = self.tox_args
32+
if args:
33+
args = shlex.split(self.tox_args)
34+
errno = tox.cmdline(args)
35+
sys.exit(errno)
36+
37+
1438
setup(name='simplepeg',
1539
version='1.0.3',
1640
description='Python version of SimplePEG',
@@ -26,8 +50,8 @@ def license_text():
2650
author_email='[email protected]',
2751
keywords='peg parser grammar',
2852
license=license_text(),
29-
test_suite='nose.collector',
30-
tests_require=['nose'],
53+
tests_require=['pytest', 'tox'],
54+
cmdclass={'test': Tox},
3155
packages=['simplepeg'],
3256
include_package_data=True,
3357
zip_safe=False)

tests/test_speg_fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from os import path as op
2+
import json
23

34
import pytest
45

@@ -17,4 +18,4 @@ def test_speg(grammar_file):
1718
for postfix in ('', '.txt', '.json')]
1819
speg = SPEG()
1920
ast = speg.parse(grammar, text)
20-
assert ast.to_json() == result
21+
assert json.loads(ast.to_json()) == json.loads(result)

tox.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[tox]
2+
envlist=py27
3+
[testenv]
4+
changedir=tests
5+
deps=pytest
6+
commands=py.test --basetemp={envtmpdir}
7+
setenv = PYTHONPATH = {toxinidir}

0 commit comments

Comments
 (0)