question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
t8y8commented, Sep 2, 2016

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

0reactions
t8y8commented, Sep 2, 2016

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)
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Can't get a consistent path to setup script from installation ...
You need to have a pyproject.toml file in your package. I have no idea why this makes the error go away, but it...
Read more >
Knowledge Bits — Common Python Packaging Mistakes
An overview of common mistakes made in creating & building a Python package and how to avoid them.
Read more >
Packaging and distributing projects
Before releasing on main PyPI repo, you might prefer training with the PyPI test site which is cleaned on a semi regular basis....
Read more >
PyPI Repositories - JFrog - JFrog Documentation
To define a virtual PyPI repository, from the Administration module, go to Repositories | Repositories | Virtual, set its Package Type to be ......
Read more >
git-clone Documentation - Git
DESCRIPTION. Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found