Permalink
Browse files

Fix painful relative import issues for Py3

Also fix the setup.py tests_require option
Furthermore, fix the run_tests script
Still broken: secondary tests and extensions
Broken: ability to run pyresttest/resttest.py as script
  • Loading branch information...
1 parent 0cff025 commit 25b8a731e2fde95dcb91aeb19e4ed19e57a5e382 @svanoort committed Dec 21, 2015
View
@@ -0,0 +1,6 @@
+This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
+
+This directory caches those eggs to prevent repeated downloads.
+
+However, it is safe to delete this directory.
+
@@ -139,6 +139,7 @@ node {
stage 'Basic Test: running from setup.py install'
execute_install_testset([testPy27_directInstall, testPy26_directInstall, testPy34_directInstall], test_direct_names)
+ // TODO Add ability to run all tests before showing failures
// TODO Functional test using content-test against a docker container running the Django testapp (with a docker link)
// TODO TestPyPi install & test
// TODO VirtualEnv test
@@ -1,2 +1,2 @@
-__all__ = ["resttest", "generators", "binding", "parsing",
- "validators", "contenthandling", "benchmarks", "tests"]
+#__all__ = ["resttest", "generators", "binding", "parsing",
+# "validators", "contenthandling", "benchmarks", "tests", "six"]
@@ -1,16 +1,19 @@
import math
import json
import pycurl
-from tests import Test
-import tests
import sys
-from parsing import *
+
+from . import tests
+from .tests import Test
+from . import parsing
+from .parsing import *
# Python 2/3 switches
if sys.version_info[0] > 2:
from past.builtins import basestring
# Python 3 compatibility shims
+from . import six
from six import binary_type
from six import text_type
@@ -1,6 +1,8 @@
import os
import sys
-from parsing import *
+
+from . import parsing
+from .parsing import *
# Python 2/3 switches
PYTHON_MAJOR_VERSION = sys.version_info[0]
@@ -9,14 +9,17 @@
from django.core.management import call_command
-from tests import Test
-from binding import Context
-import resttest
-import validators
+from . import tests
+from .tests import Test
+from . import binding
+from .binding import Context
+from . import resttest
+from . import validators
# Python 2/3 compat shims
-from six import text_type
-from six import binary_type
+from . import six
+from .six import text_type
+from .six import binary_type
# Django testing settings, initial configuration
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings")
@@ -4,8 +4,8 @@
import logging
import sys
-from parsing import flatten_dictionaries, lowercase_keys, safe_to_bool
-import parsing
+from . import parsing
+from .parsing import flatten_dictionaries, lowercase_keys, safe_to_bool
# Python 3 compatibility
if sys.version_info[0] > 2:
@@ -1,7 +1,10 @@
+from __future__ import absolute_import
import sys
import string
+
# Python 3 compatibility shims
+from . import six
from six import binary_type
from six import text_type
@@ -27,17 +27,22 @@
from builtins import range as xrange
ESCAPE_DECODING = 'unicode_escape'
-from six import text_type
+from . import six
+from .six import text_type
# Pyresttest internals
-from binding import Context
-import generators
-from generators import parse_generator
-from parsing import flatten_dictionaries, lowercase_keys, safe_to_bool, safe_to_json
-import validators
-from validators import Failure
-from tests import Test, DEFAULT_TIMEOUT
-from benchmarks import Benchmark, AGGREGATES, METRICS, parse_benchmark
+from . import binding
+from .binding import Context
+from . import generators
+from .generators import parse_generator
+from . import parsing
+from .parsing import flatten_dictionaries, lowercase_keys, safe_to_bool, safe_to_json
+from . import validators
+from .validators import Failure
+from . import tests
+from .tests import Test, DEFAULT_TIMEOUT
+from . import benchmarks
+from .benchmarks import Benchmark, AGGREGATES, METRICS, parse_benchmark
"""
Executable class, ties everything together into the framework.
@@ -1,5 +1,6 @@
import unittest
-from benchmarks import *
+from . import benchmarks
+from .benchmarks import *
class BenchmarkTest(unittest.TestCase):
@@ -1,5 +1,6 @@
import unittest
-from binding import Context
+from . import binding
+from .binding import Context
def count_gen(): # Generator that counts up from 1
@@ -2,8 +2,10 @@
import unittest
import string
import os
-from contenthandling import ContentHandler
-from binding import Context
+from . import contenthandling
+from .contenthandling import ContentHandler
+from . import binding
+from .binding import Context
class ContentHandlerTest(unittest.TestCase):
@@ -1,10 +1,11 @@
import unittest
-import generators
import string
import os
import types
import sys
+from . import generators
+
# Python 3 compatibility
if sys.version_info[0] == 3:
from builtins import range as xrange
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
import unittest
-from parsing import *
+import sys
+
+from . import parsing
+from .parsing import *
PYTHON_MAJOR_VERSION = sys.version_info[0]
@@ -2,10 +2,10 @@
import math
import string
import yaml
-
-import resttest
import unittest
-from resttest import *
+
+from . import resttest
+from .resttest import *
class TestRestTest(unittest.TestCase):
@@ -2,10 +2,14 @@
import unittest
import string
-from tests import *
-from binding import Context
-from contenthandling import ContentHandler
-import generators
+
+from . import tests
+from .tests import *
+from . import binding
+from .binding import Context
+from . import contenthandling
+from .contenthandling import ContentHandler
+from . import generators
PYTHON_MAJOR_VERSION = sys.version_info[0]
if PYTHON_MAJOR_VERSION > 2:
@@ -14,8 +18,9 @@
import mock
# Python 3 compatibility shims
-from six import binary_type
-from six import text_type
+from . import six
+from .six import binary_type
+from .six import text_type
class TestsTest(unittest.TestCase):
""" Testing for basic REST test methods, how meta! """
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import unittest
-import validators
-from binding import Context
+from . import validators
+from . import binding
+from .binding import Context
class ValidatorsTest(unittest.TestCase):
""" Testing for validators and extract functions """
View
@@ -3,10 +3,14 @@
import copy
import json
import pycurl
-from contenthandling import ContentHandler
-import validators
import sys
-from parsing import *
+
+
+from . import contenthandling
+from .contenthandling import ContentHandler
+from . import validators
+from . import parsing
+from .parsing import *
# Find the best implementation available on this platform
try:
@@ -26,10 +30,11 @@
import urlparse
# Python 3 compatibility shims
-from six import binary_type
-from six import text_type
-from six import iteritems
-from six.moves import filter as ifilter
+from . import six
+from .six import binary_type
+from .six import text_type
+from .six import iteritems
+from .six.moves import filter as ifilter
"""
Pull out the Test objects and logic associated with them
@@ -3,11 +3,13 @@
import operator
import traceback
import string
-import parsing
import os
import re
import sys
+# Local module imports
+from . import parsing
+
# Python 3 compatibility shims
from six import binary_type
from six import text_type
View
@@ -5,9 +5,9 @@
python -c 'import sys; exit(sys.version_info[0:2] < (2,7))' # Return exit code 1 if before python 2.7
if [ $? -ne 0 ]; then # Module discover pip-installed for test discovery
- python -m discover -s pyresttest -p 'test_*.py'
+ python -m discover
else
- python -m unittest discover -s pyresttest -p 'test_*.py'
+ python -m unittest discover
fi
@@ -17,7 +17,7 @@ if [ $? -ne 0 ]; then
fi
# Command-line call tests (use github API)
-python pyresttest/functionaltest.py
+python -m unittest pyresttest.functionaltest
if [ $? -ne 0 ]; then
exit 1
View
@@ -38,7 +38,7 @@
'pyresttest.benchmarks', 'pyresttest.tests', 'pyresttest.ext.validator_jsonschema', 'pyresttest.six'],
license='Apache License, Version 2.0',
install_requires=dependencies,
- test_require=test_dependencies,
+ tests_require=test_dependencies,
extras_require= {
'JSONPath': {'jsonpath'}
},

0 comments on commit 25b8a73

Please sign in to comment.