move-coop / parsons

A python library of connectors for the progressive community.
https://www.parsonsproject.org/
Other
257 stars 125 forks source link

[Bug] FAILED test/test_etl.py::TestParsonsTable::test_from_petl - TypeError: The only supported seed types are: None, #893

Closed NirTatcher closed 9 months ago

NirTatcher commented 9 months ago

Detailed Description

Tried to follow the steps at https://move-coop.github.io/parsons/html/stable/contributing#contributing-code-to-parsons When I try to run the Unit tests (pytest -rf test/) I get an error on the test_etl.py. Did anyone else experienced this issue? Is it OK to start working on changes although this test is failing? The full output: ============================================================================== FAILURES =============================================================================== _ TestParsonsTable.test_frompetl

self =

def test_from_petl(self):

    nrows = 10
    ptbl = petl.dummytable(numrows=nrows)
  tbl = Table(ptbl)

test/test_etl.py:59:


parsons/etl/table.py:54: in init if not self.is_valid_table(): parsons/etl/table.py:242: in is_validtable if not self.table: ../venv/lib/python3.11/site-packages/petl/util/base.py:28: in len return sum(1 for in self) ../venv/lib/python3.11/site-packages/petl/util/base.py:28: in return sum(1 for _ in self) ../venv/lib/python3.11/site-packages/petl/util/random.py:170: in iter random.seed(seed)


self = <random.Random object at 0x11f85b220>, a = datetime.datetime(2023, 9, 26, 17, 13, 18, 984197), version = 2

def seed(self, a=None, version=2):
    """Initialize internal state from a seed.

    The only supported seed types are None, int, float,
    str, bytes, and bytearray.

    None or no argument seeds from current time or from an operating
    system specific randomness source if available.

    If *a* is an int, all bits are used.

    For version 2 (the default), all of the bits are used if *a* is a str,
    bytes, or bytearray.  For version 1 (provided for reproducing random
    sequences from older versions of Python), the algorithm for str and
    bytes generates a narrower range of seeds.

    """

    if version == 1 and isinstance(a, (str, bytes)):
        a = a.decode('latin-1') if isinstance(a, bytes) else a
        x = ord(a[0]) << 7 if a else 0
        for c in map(ord, a):
            x = ((1000003 * x) ^ c) & 0xFFFFFFFFFFFFFFFF
        x ^= len(a)
        a = -2 if x == -1 else x

    elif version == 2 and isinstance(a, (str, bytes, bytearray)):
        if isinstance(a, str):
            a = a.encode()
        a = int.from_bytes(a + _sha512(a).digest())

    elif not isinstance(a, (type(None), int, float, str, bytes, bytearray)):
      raise TypeError('The only supported seed types are: None,\n'

'int, float, str, bytes, and bytearray.') E TypeError: The only supported seed types are: None, E int, float, str, bytes, and bytearray.

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/random.py:160: TypeError ======================================================================= short test summary info ======================================================================= FAILED test/test_etl.py::TestParsonsTable::test_from_petl - TypeError: The only supported seed types are: None, ================================================= 1 failed, 710 passed, 188 skipped, 1 xfailed, 12 warnings in 26.71s =================================================

To Reproduce

Try to follow the steps at https://move-coop.github.io/parsons/html/stable/contributing#making-changes-to-parsons

Your Environment

Additional Context

Priority

ASAP?

NirTatcher commented 9 months ago

Issue was I was using Python version 3.11 and the parsons project support's version 3.10, I downgraded the version and its working