[solved] Unittest error - _p_serial must be an 8-character bytes array

Hoping someone can help with this error if you've seen it before. I'm trying to run unit tests on my module but the error seems to be unrelated and a result of something wrong with ZODB. Plone 5.0.5

(plone50) C:\Plone5>bin\test.exe -s ims.entrez
Running ims.entrez.testing.ims.entrez:Integration tests:
  Set up plone.testing.zca.LayerCleanup in 0.000 seconds.
  Set up plone.testing.z2.Startup > c:\plone5\eggs\zodb3-3.10.5-py2.7-win-amd64.egg\zodb\connection.py(916)_setstate()
-> obj._p_serial = serial
(Pdb) serial
"'\\x03\\xce,\\x14}\\xdd\\xdd\\xdd'"
(Pdb) len(serial)
28
(Pdb) serial="'\x03\xce,\x14}\xdd\xdd\xdd'"
(Pdb) c
Traceback (most recent call last):
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 366, in run_layer
    setup_layer(options, layer, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 628, in setup_layer
    setup_layer(options, base, setup_layers)
  File "c:\plone5\eggs\zope.testing-3.9.7-py2.7.egg\zope\testing\testrunner\runner.py", line 633, in setup_layer
    layer.setUp()
  File "c:\plone5\eggs\plone.testing-4.1.1-py2.7.egg\plone\testing\z2.py", line 346, in setUp
    self.setUpApp()
  File "c:\plone5\eggs\plone.testing-4.1.1-py2.7.egg\plone\testing\z2.py", line 626, in setUpApp
    Zope2.startup()
  File "c:\plone5\eggs\zope2-2.13.24-py2.7.egg\Zope2\__init__.py", line 47, in startup
    _startup()
  File "c:\plone5\eggs\zope2-2.13.24-py2.7.egg\Zope2\App\startup.py", line 123, in startup
    DB, 'Application', OFS.Application.Application, ()
  File "c:\plone5\eggs\zope2-2.13.24-py2.7.egg\App\ZApplication.py", line 31, in __init__
    if not root.has_key(name):
  File "c:\plone5\eggs\zodb3-3.10.5-py2.7-win-amd64.egg\ZODB\Connection.py", line 860, in setstate
    self._setstate(obj)
  File "c:\plone5\eggs\zodb3-3.10.5-py2.7-win-amd64.egg\ZODB\Connection.py", line 916, in _setstate
    obj._p_serial = serial
ValueError: _p_serial must be an 8-character bytes array

Tearing down left over layers:
  Tear down plone.testing.zca.LayerCleanup in 0.000 seconds.

Comparing the value of "serial" to when I start Plone regularly, it looks like it's incorrectly getting double slashes when I run bin\test

I had persistent 4.2.4.2 (not to be confused with Persistence) installed in my virtualenv which is incompatible with ZODB 3.10.5 which is what Plone 5.0.5 uses. I don't believe this is an issue in Plone 5.1+ because those versions use a newer ZODB that is compatible with persistent (persistent is one of the components of the old ZODB3 that was broken up into invidual packages, along with ZEO, ZODB, and BTrees).

Hopefully no one else runs into this, but there's a good chance I will forget about this in 3 months and google my own solution to realize my mistake :wink: