Test failures with python3 #149

Closed
bkabrda opened this Issue Mar 19, 2013 · 12 comments

Projects

None yet

3 participants

@bkabrda
bkabrda commented Mar 19, 2013

Hi,
I'm experiencing dozens of failures with Python 3. Is this expected or is something wrong on my side? It seems that some of the failures are connected with random order of dict items in str(headers) in ReplayingConnection.request, but there are also other.

@jacquev6
Member

Hello,

According to Travis, PyGithub's tests pass with Python 3, so this is strange. But after #142 and #143, nothing surprises me :-D

Can you please give me:

  • which version of Python you use (output of python3 --version)
  • on what platform (Version of Windows, or output of uname -a on Unix-like systems)
  • which version of PyGithub you use

If you can also create a Gist with the output of python3 setup.py test, that would be great!

Thanks,

@jacquev6 jacquev6 was assigned Mar 19, 2013
@bkabrda
bkabrda commented Mar 20, 2013

Here you go:

  • Python 3.3.0
  • Fedora 18 x86_64,
  • Linux zizalka 3.8.2-206.fc18.x86_64 #1 SMP Fri Mar 8 15:03:34 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
  • PyGitHub 1.11.1
  • Gist: https://gist.github.com/bkabrda/5202929 (but note that the failures seem to be somehow random, depending on how the dict are ordered in each run)
@bilderbuchi

here's what I immediately notice: you're using Pygithub 1.11.1 - the current version is 1.12.2, do you also get the errors with the current version?

@jacquev6
Member

I can reproduce the issue with all versions of PyGithub using Python 3.3 on Windows. It looks like Python 3.3 does not output dicts in the same order as Python 2.5 to 3.2 :-(

My design is bad, I will fix the test framework soon to cope with that.

@bkabrda
bkabrda commented Mar 20, 2013

@jacquev6 thank you!

@bilderbuchi

I thought that dict order is something you shouldn't rely on, anyway?

@bkabrda
bkabrda commented Mar 20, 2013

@bilderbuchi that is true, however the dicts used to be "ordered". I remember the same thing happening to Ruby hashes, that were recently (half a year?) changed to get random seed on every interpreter execution as a defence before hash collision attacks. (Therefore you get the same order during one execution of an interpreter.) This was causing tons of random failures of tests that expected the hashes to be in a certain order...
I believe that this is the same with Python 3.3, but I can't find any reference that would confirm this.

@bilderbuchi

What I found here:

Keys and values are iterated over in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary’s history of insertions and deletions. If keys, values and items views are iterated over with no intervening modifications to the dictionary, the order of items will directly correspond.

@jacquev6
Member

@bilderbuchi Yes that's why I say that "my design is bad". But it used to work. Well, fixing will not be that difficult.

@jacquev6 jacquev6 added a commit that referenced this issue Mar 21, 2013
@jacquev6 jacquev6 Fix tests on Python 3.3 (issue #149)
The output order of dicts has changed
7a9c0b9
@jacquev6
Member

Fixed. This was a bit painful, in fact :-D And I've added Python 3.3 to the Travis setup.

And now Python 2.5 tests are broken on Travis... Well, I'll fix that later.

@jacquev6
Member

Fixed: Travis

@jacquev6 jacquev6 closed this Mar 21, 2013
@bkabrda
bkabrda commented Mar 22, 2013

Thanks, I think I have a pretty good idea about how to test the non-determinstic dicts in Python 3.3. I'll try to find some time to put together a pull request and make all the tests run on py33.

@bkabrda bkabrda added the v1 label Mar 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment