Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2/3 support #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Python 2/3 support #103

wants to merge 1 commit into from

Conversation

s-celles
Copy link
Contributor

Try to solve #100 but there is still an issue with

  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

which seem to be raised because of the use of UserDict in pingo.utils.py

@ramalho
Copy link
Contributor

ramalho commented Nov 26, 2015

Thanks for this contribution @scls19fr! Can you tell us exactly where that failure is happening? The full traceback would suffice. Thanks!

@s-celles
Copy link
Contributor Author

test_capability_response (pingo.arduino.test_util_firmata.FirmataCapabilityDetect) ... ok
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
test_board (pingo.detect.test_detect.DetectBasics) ... ERROR
test_read_cpu_info (pingo.detect.test_detect.DetectBasics) ... SKIP: Not Linux
test_wrong_output_mode (pingo.ghost.tests.test_ghost.GhostAnalogExceptions) ... ERROR
test_200ohmRead (pingo.ghost.tests.test_ghost.GhostAnalogRead) ... ERROR
test_pin_ratio (pingo.ghost.tests.test_ghost.GhostAnalogRead) ... ERROR
test_button (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... SKIP: Not automatic enough.
test_digital_pins (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
test_filter (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
Wire this DigitalPin directly into VDD ... ERROR
test_led (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
test_list_pins (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
test_select (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
test_toggle (pingo.ghost.tests.test_ghost.GhostBoardBasics) ... ERROR
test_disabled_pin (pingo.ghost.tests.test_ghost.GhostBoardExceptions) ... ERROR
test_wrong_pin_mode_in (pingo.ghost.tests.test_ghost.GhostBoardExceptions) ... ERROR
test_dot50_duty_cycle (pingo.ghost.tests.test_ghost.GhostPwm) ... ERROR
test_frequency (pingo.ghost.tests.test_ghost.GhostPwm) ... ERROR
test_wrong_analog_mode (pingo.ghost.tests.test_ghost.GhostPwmExceptions) ... ERROR
test_wrong_read_state (pingo.ghost.tests.test_ghost.GhostPwmExceptions) ... ERROR
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
Failure: ImportError (No module named 'RPi') ... ERROR
test_run_both_callback (pingo.parts.test.test_switch.TestSwitch) ... ok
test_run_down_callback (pingo.parts.test.test_switch.TestSwitch) ... ok
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
Failure: TypeError (iter() returned non-iterator of type 'KeysView') ... ERROR
test_getitem (pingo.test_utils.StrKeyDictTest) ... ok
test_in (pingo.test_utils.StrKeyDictTest) ... ok
test_normalize (pingo.test_utils.StrKeyDictTest) ... ok
test_setitem (pingo.test_utils.StrKeyDictTest) ... ok
test_update (pingo.test_utils.StrKeyDictTest) ... ERROR

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/arduino/tests/test_arduino.py", line 9, in <module>
    running_on_arduino = check_board(pingo.arduino.ArduinoFirmata)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/bbb/tests/test_bbb.py", line 7, in <module>
    running_on_beaglebone = check_board(pingo.bbb.BeagleBoneBlack)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_board (pingo.detect.test_detect.DetectBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/test_detect.py", line 11, in test_board
    board = pingo.detect.get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_wrong_output_mode (pingo.ghost.tests.test_ghost.GhostAnalogExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_200ohmRead (pingo.ghost.tests.test_ghost.GhostAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_pin_ratio (pingo.ghost.tests.test_ghost.GhostAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_digital_pins (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_filter (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Wire this DigitalPin directly into VDD
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_led (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_list_pins (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_select (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_toggle (pingo.ghost.tests.test_ghost.GhostBoardBasics)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_disabled_pin (pingo.ghost.tests.test_ghost.GhostBoardExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_wrong_pin_mode_in (pingo.ghost.tests.test_ghost.GhostBoardExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_dot50_duty_cycle (pingo.ghost.tests.test_ghost.GhostPwm)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_frequency (pingo.ghost.tests.test_ghost.GhostPwm)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_wrong_analog_mode (pingo.ghost.tests.test_ghost.GhostPwmExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_wrong_read_state (pingo.ghost.tests.test_ghost.GhostPwmExceptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/tests/test_ghost.py", line 13, in setUp
    self.board = pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/intel/tests/test_edison.py", line 8, in <module>
    running_on_galileo = check_board(pingo.intel.Edison)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/intel/tests/test_galileo.py", line 8, in <module>
    running_on_galileo = check_board(pingo.intel.Galileo2)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: ImportError (No module named 'RPi')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 245, in load_module
    return load_package(name, filename)
  File "//anaconda/lib/python3.4/imp.py", line 217, in load_package
    return methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/parts/spi/__init__.py", line 1, in <module>
    from .mcp3008 import Mcp3008  # noqa
  File "/Users/scls/github/scls19fr/pingo-py/pingo/parts/spi/mcp3008.py", line 10, in <module>
    import RPi.GPIO as GPIO
ImportError: No module named 'RPi'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/pcduino/tests/test_pcduino.py", line 8, in <module>
    running_on_pcduino = check_board(pingo.pcduino.PcDuino)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/rpi/tests/test_rpi.py", line 7, in <module>
    running_on_raspberry = check_board(pingo.rpi.RaspberryPi)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: Failure: TypeError (iter() returned non-iterator of type 'KeysView')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/udoo/tests/test_udoo.py", line 7, in <module>
    running_on_udoo = check_board(pingo.udoo.Udoo)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 51, in __init__
    for location, pin in iteritems(self.pins):
  File "//anaconda/lib/python3.4/_collections_abc.py", line 497, in __iter__
    for key in self._mapping:
TypeError: iter() returned non-iterator of type 'KeysView'

======================================================================
ERROR: test_update (pingo.test_utils.StrKeyDictTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/scls/github/scls19fr/pingo-py/pingo/test_utils.py", line 35, in test_update
    assert set(self.d.keys()) == set(['2', '4', '6', '8'])
  File "//anaconda/lib/python3.4/_collections_abc.py", line 476, in __iter__
    yield from self._mapping
TypeError: iter() returned non-iterator of type 'KeysView'

----------------------------------------------------------------------
Ran 35 tests in 1.045s

FAILED (SKIP=2, errors=26)

@s-celles
Copy link
Contributor Author

I also tried to change in compat.py (iteritems and/or iterkeys)

return func(**kwargs)

to

return list(func(**kwargs))

(to be sure to return an "iterable")

but it raised

  File "//anaconda/lib/python3.4/_collections_abc.py", line 476, in __iter__
    yield from self._mapping
  File "/Users/scls/github/scls19fr/pingo-py/pingo/util.py", line 69, in __iter__
    return iterkeys(self)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/compat.py", line 20, in iterkeys
    return list(func(**kwargs))
  File "//anaconda/lib/python3.4/_collections_abc.py", line 476, in __iter__
    yield from self._mapping
  File "/Users/scls/github/scls19fr/pingo-py/pingo/util.py", line 69, in __iter__
    return iterkeys(self)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/compat.py", line 20, in iterkeys
    return list(func(**kwargs))

  ...

  File "//anaconda/lib/python3.4/_collections_abc.py", line 476, in __iter__
    yield from self._mapping
  File "/Users/scls/github/scls19fr/pingo-py/pingo/util.py", line 69, in __iter__
    return iterkeys(self)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/compat.py", line 20, in iterkeys
    return list(func(**kwargs))
  File "//anaconda/lib/python3.4/_collections_abc.py", line 436, in keys
    return KeysView(self)
RuntimeError: maximum recursion depth exceeded

@ramalho
Copy link
Contributor

ramalho commented Nov 26, 2015

I am looking into this @scls19fr

@s-celles
Copy link
Contributor Author

I've found this http://stackoverflow.com/questions/3387691/python-how-to-perfectly-override-a-dict

So I implemented StrKeyDict this way

class StrKeyDict(collections.MutableMapping):
    """StrKeyDict always converts non-string keys to `str`

    Tests for item retrieval using `d[key]` notation::

        >>> d = StrKeyDict([('2', 'two'), ('4', 'four')])
        >>> d['2']
        'two'
        >>> d[4]
        'four'
        >>> d[1]
        Traceback (most recent call last):
          ...
        KeyError: '1'

    Tests for the `in` operator::

        >>> 2 in d
        True
        >>> 1 in d
        False

    Test for item assignment using non-string key::

        >>> d[0] = 'zero'
        >>> d['0']
        'zero'

    Test for case-insensitive retrieval::

        >>> d['A0'] = 'A-zero'
        >>> d['a0']
        'A-zero'
        >>> del d['A0']

    Tests for update using a `dict` or a sequence of pairs::

        >>> d.update({6:'six', '8':'eight'})
        >>> sorted(d.keys())
        ['0', '2', '4', '6', '8']
        >>> d.update([(10, 'ten'), ('12', 'twelve')])
        >>> sorted(d.keys())
        ['0', '10', '12', '2', '4', '6', '8']
        >>> d.update([1, 3, 5])
        Traceback (most recent call last):
          ...
        TypeError: 'int' object is not iterable

    """
    def __init__(self, *args, **kwargs):
        self.store = collections.OrderedDict()
        self.update(dict(*args, **kwargs))  # use the free update to set keys

    def __getitem__(self, key):
        return self.store[self.__keytransform__(key)]

    def __setitem__(self, key, value):
        self.store[self.__keytransform__(key)] = value

    def __delitem__(self, key):
        del self.store[self.__keytransform__(key)]

    def __iter__(self):
        return iter(self.store)

    def __len__(self):
        return len(self.store)

    def __keytransform__(self, key):
        return str(key).upper()

    def update(self, iterable=None, **kwds):
        if iterable is not None:
            if isinstance(iterable, collections.Mapping):
                pairs = iterable.items()
            else:
                pairs = ((k, v) for k, v in iterable)
            for key, value in pairs:
                self[key] = value
        if kwds:
            self.update(kwds)

but tests with Python 3 raises

======================================================================
ERROR: Failure: WrongPinMode ()
----------------------------------------------------------------------
Traceback (most recent call last):
  File "//anaconda/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "//anaconda/lib/python3.4/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "//anaconda/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "//anaconda/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "//anaconda/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/scls/github/scls19fr/pingo-py/pingo/arduino/tests/test_arduino.py", line 9, in <module>
    running_on_arduino = check_board(pingo.arduino.ArduinoFirmata)
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/__init__.py", line 13, in check_board
    current = get_board()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/detect/detect.py", line 59, in get_board
    return pingo.ghost.GhostBoard()
  File "/Users/scls/github/scls19fr/pingo-py/pingo/ghost/ghost.py", line 52, in __init__
    self._pin_states[location] = 0 if hasattr(pin, 'state') else None
  File "/Users/scls/github/scls19fr/pingo-py/pingo/board.py", line 292, in state
    raise WrongPinMode()
pingo.board.WrongPinMode

same tests with Python 2 doesn't raises these errors

@s-celles
Copy link
Contributor Author

Hi @ramalho Any news about this ?

@s-celles
Copy link
Contributor Author

Can we tackle first Enum issue and after tackle this one ?

@s-celles s-celles mentioned this pull request May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants