зеркало из https://github.com/mozilla/PyHive.git
Switch to py.test
This commit is contained in:
Родитель
2fde31f444
Коммит
1b0616abd2
|
@ -0,0 +1,2 @@
|
|||
[run]
|
||||
branch = True
|
|
@ -3,6 +3,8 @@ cover/
|
|||
/dist/
|
||||
.DS_Store
|
||||
*.egg
|
||||
/env/
|
||||
/htmlcov/
|
||||
.project
|
||||
*.pyc
|
||||
.pydevproject
|
||||
|
|
|
@ -50,7 +50,7 @@ Run the following in an environment with Hive/Presto::
|
|||
./scripts/make_test_tables.sh
|
||||
virtualenv env
|
||||
source env/bin/activate
|
||||
pip install -r test_requirements.txt
|
||||
nosetests
|
||||
pip install -r dev_requirements.txt
|
||||
py.test
|
||||
|
||||
WARNING: This drops/creates tables named ``one_row``, ``one_row_complex``, and ``many_rows``.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
mock>=1.0.0
|
||||
nose
|
||||
pytest
|
||||
pytest-cov
|
||||
requests>=1.0.0
|
||||
sasl>=0.1.3
|
||||
sqlalchemy>=0.5.0
|
|
@ -1 +1 @@
|
|||
__version__ = '0.1.0-SNAPSHOT'
|
||||
__version__ = '0.1.0'
|
||||
|
|
|
@ -7,7 +7,6 @@ from pyhive import exc
|
|||
import abc
|
||||
import contextlib
|
||||
import functools
|
||||
import unittest
|
||||
|
||||
|
||||
def with_cursor(fn):
|
||||
|
@ -23,9 +22,8 @@ def with_cursor(fn):
|
|||
return wrapped_fn
|
||||
|
||||
|
||||
class DBAPITestCase(unittest.TestCase):
|
||||
class DBAPITestCase(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
__test__ = False
|
||||
|
||||
@abc.abstractmethod
|
||||
def connect(self):
|
||||
|
|
|
@ -9,7 +9,6 @@ from sqlalchemy.sql import expression
|
|||
import abc
|
||||
import contextlib
|
||||
import functools
|
||||
import unittest
|
||||
|
||||
|
||||
def with_engine_connection(fn):
|
||||
|
@ -28,9 +27,8 @@ def with_engine_connection(fn):
|
|||
return wrapped_fn
|
||||
|
||||
|
||||
class SqlAlchemyTestCase(unittest.TestCase):
|
||||
class SqlAlchemyTestCase(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
__test__ = False
|
||||
|
||||
@with_engine_connection
|
||||
def test_basic_query(self, engine, connection):
|
||||
|
|
|
@ -12,11 +12,12 @@ from pyhive.tests.dbapi_test_case import DBAPITestCase
|
|||
from pyhive.tests.dbapi_test_case import with_cursor
|
||||
import contextlib
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
_HOST = 'localhost'
|
||||
|
||||
|
||||
class TestHive(DBAPITestCase):
|
||||
class TestHive(unittest.TestCase, DBAPITestCase):
|
||||
__test__ = True
|
||||
|
||||
def connect(self):
|
||||
|
|
|
@ -11,11 +11,12 @@ from pyhive import presto
|
|||
from pyhive.tests.dbapi_test_case import DBAPITestCase
|
||||
from pyhive.tests.dbapi_test_case import with_cursor
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
_HOST = 'localhost'
|
||||
|
||||
|
||||
class TestPresto(DBAPITestCase):
|
||||
class TestPresto(unittest.TestCase, DBAPITestCase):
|
||||
__test__ = True
|
||||
|
||||
def connect(self):
|
||||
|
|
|
@ -10,6 +10,7 @@ from sqlalchemy.types import String
|
|||
import contextlib
|
||||
import datetime
|
||||
import decimal
|
||||
import unittest
|
||||
|
||||
_ONE_ROW_COMPLEX_CONTENTS = [
|
||||
True,
|
||||
|
@ -30,9 +31,7 @@ _ONE_ROW_COMPLEX_CONTENTS = [
|
|||
]
|
||||
|
||||
|
||||
class TestSqlAlchemyHive(SqlAlchemyTestCase):
|
||||
__test__ = True
|
||||
|
||||
class TestSqlAlchemyHive(unittest.TestCase, SqlAlchemyTestCase):
|
||||
def create_engine(self):
|
||||
return create_engine('hive://hadoop@localhost:10000/default')
|
||||
|
||||
|
|
|
@ -8,11 +8,10 @@ from sqlalchemy.schema import MetaData
|
|||
from sqlalchemy.schema import Table
|
||||
from sqlalchemy.types import String
|
||||
import contextlib
|
||||
import unittest
|
||||
|
||||
|
||||
class TestSqlAlchemyPresto(SqlAlchemyTestCase):
|
||||
__test__ = True
|
||||
|
||||
class TestSqlAlchemyPresto(unittest.TestCase, SqlAlchemyTestCase):
|
||||
def create_engine(self):
|
||||
return create_engine('presto://localhost:8080/hive/default?source={}'.format(self.id()))
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[egg_info]
|
||||
tag_build = dev
|
||||
|
||||
[pytest]
|
||||
addopts = --cov pyhive --cov-report html --cov-report term
|
||||
norecursedirs = env
|
||||
python_files = test_*.py
|
20
setup.py
20
setup.py
|
@ -1,7 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools.command.test import test as TestCommand
|
||||
import pyhive
|
||||
import sys
|
||||
|
||||
|
||||
class PyTest(TestCommand):
|
||||
def finalize_options(self):
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_args = []
|
||||
self.test_suite = True
|
||||
|
||||
def run_tests(self):
|
||||
#import here, cause outside the eggs aren't loaded
|
||||
import pytest
|
||||
errno = pytest.main(self.test_args)
|
||||
sys.exit(errno)
|
||||
|
||||
with open('README.rst') as readme:
|
||||
long_description = readme.read()
|
||||
|
@ -23,15 +38,16 @@ setup(
|
|||
"Hive": ['sasl>=0.1.3', 'thrift>=0.8.0'],
|
||||
"SQLAlchemy": ['sqlalchemy>=0.5.0'],
|
||||
},
|
||||
test_suite='nose.collector',
|
||||
tests_require=[
|
||||
'mock>=1.0.0',
|
||||
'nose',
|
||||
'pytest',
|
||||
'pytest-cov',
|
||||
'requests>=1.0.0',
|
||||
'sasl>=0.1.3',
|
||||
'sqlalchemy>=0.5.0',
|
||||
'thrift>=0.8.0',
|
||||
],
|
||||
cmdclass={'test': PyTest},
|
||||
package_data={
|
||||
'': ['*.rst'],
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче