Skip to content

setup.py test doesn't pass on clean repo clone #3

Closed

Description

@t8y8

Python 3.5:

[1/1] test
test test crashed -- Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/test/regrtest.py", line 1292, in runtest_inner
    the_module = importlib.import_module(abstest)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'test.test'

1 test failed:
    test

Python 2.7:

running build_ext
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    'requests-mock>=1.0,<1.1a0'
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/test.py", line 138, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/test.py", line 118, in with_project_on_sys_path
    func()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/test.py", line 164, in run_tests
    testLoader = cks
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 103, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/test.py", line 35, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/autotest.py", line 5, in <module>
    from test import regrtest
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/regrtest.py", line 183, in <module>
    for module in sys.modules.itervalues():
RuntimeError: dictionary changed size during iteration

Activity

  1. added this to the 0.1 milestone on Sep 2, 2016
  2. graysonarts commented on Sep 2, 2016

    @graysonarts
    Contributor

    @shinchris This is because you are missing __init__.py in the test directory.

  3. t8y8 commented on Sep 2, 2016

    @t8y8
    ContributorAuthor

    Adding an empty __init__ file gets them to run, I've got 9 failures on python 3

    It's due to relative import problems.

    I fixed one by saying from .exceptions import <blah> but then there's another.

    Example:

    ImportError: Failed to import test module: test_workbook
    Traceback (most recent call last):
      File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/unittest/loader.py", line 153, in loadTestsFromName
        module = __import__(module_name)
      File "/Users/tdoyle/Documents/py/server-api-python/test/test_workbook.py", line 4, in <module>
        import tableauserverapi as TSA
      File "/Users/tdoyle/Documents/py/server-api-python/tableauserverapi/__init__.py", line 2, in <module>
        from .models import ConnectionItem, DatasourceItem,\
      File "/Users/tdoyle/Documents/py/server-api-python/tableauserverapi/models/__init__.py", line 2, in <module>
        from .datasource_item import DatasourceItem
      File "/Users/tdoyle/Documents/py/server-api-python/tableauserverapi/models/datasource_item.py", line 3, in <module>
        from tag_item import TagItem
    ImportError: No module named 'tag_item'
    
  4. graysonarts commented on Sep 2, 2016

    @graysonarts
    Contributor

    Definitely need to get these fixed before we can release 0.1

  5. t8y8 commented on Sep 2, 2016

    @t8y8
    ContributorAuthor

    I'm trying to run through them all now, I can attach a unified diff as a starting point

    Edit: Tests now run without import errors, still failures. Taking a look

  6. t8y8 commented on Sep 2, 2016

    @t8y8
    ContributorAuthor

    Coolio.

    Attached is a diff that will fix the import errors.
    fixed_imports.txt

    And an output from the failures. Looks like a lot of typeerrors with str:
    failures.txt

    Example:

    ======================================================================
    ERROR: test_get (test.test_group.GroupTests)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/tdoyle/Documents/py/server-api-python/test/test_group.py", line 27, in test_get
        m.get(self.baseurl, text=response_xml)
      File "/Users/tdoyle/Documents/py/envs/tableau/lib/python3.5/site-packages/requests_mock/mocker.py", line 102, in get
        return self.request(GET, *args, **kwargs)
      File "/Users/tdoyle/Documents/py/envs/tableau/lib/python3.5/site-packages/requests_mock/mocker.py", line 99, in request
        return self.register_uri(*args, **kwargs)
      File "/Users/tdoyle/Documents/py/envs/tableau/lib/python3.5/site-packages/requests_mock/adapter.py", line 304, in register_uri
        responses = [response._MatcherResponse(**k) for k in response_list]
      File "/Users/tdoyle/Documents/py/envs/tableau/lib/python3.5/site-packages/requests_mock/adapter.py", line 304, in <listcomp>
        responses = [response._MatcherResponse(**k) for k in response_list]
      File "/Users/tdoyle/Documents/py/envs/tableau/lib/python3.5/site-packages/requests_mock/response.py", line 200, in __init__
        raise TypeError('Text should be a callback or string data')
    TypeError: Text should be a callback or string data
    

    EDIT:

    It's because we read the xml in as binary mode, in python3 that's not a valid string type.

       def test_update_tags(self):
            with open(ADD_TAGS_XML, 'rb') as file:
                add_tags_xml = file.read()
            with open(UPDATE_XML, 'rb') as file:
                update_xml = file.read()
            with requests_mock.mock() as m:
                m.put(self.baseurl + '/1f951daf-4061-451a-9df1-69a8062664f2/tags', text=add_tags_xml)
    

    Could become:

       def test_update_tags(self):
            with open(ADD_TAGS_XML, 'r') as file:
                add_tags_xml = file.read()
            with open(UPDATE_XML, 'r') as file:
                update_xml = file.read()
            with requests_mock.mock() as m:
                m.put(self.baseurl + '/1f951daf-4061-451a-9df1-69a8062664f2/tags', text=add_tags_xml)
    

    Or, more correctly:

       def test_update_tags(self):
            with open(ADD_TAGS_XML, 'rb') as file:
                add_tags_xml = file.read().decode('utf-8)
            with open(UPDATE_XML, 'rb') as file:
                update_xml = file.read().decode('utf-8)
            with requests_mock.mock() as m:
                m.put(self.baseurl + '/1f951daf-4061-451a-9df1-69a8062664f2/tags', text=add_tags_xml)
    
  7. added a commit that references this issue on Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions