Test failure against Python 3.2

PYTHONPATH=build-3.2/lib nosetests --verbosity=1
# E...........
## ERROR: Failure: AttributeError ('module' object has no attribute 'translate')

Traceback (most recent call last):
  File "/usr/lib64/python3.2/site-packages/nose/failure.py", line 37, in runTest
    raise self.exc_class(self.exc_val).with_traceback(self.tb)
  File "/usr/lib64/python3.2/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib64/python3.2/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/var/tmp/portage/dev-python/requests-0.12.1/work/requests-0.12.1/requests/packages/oreos/**init**.py", line 3, in <module>
    from .core import dict_from_string
  File "/var/tmp/portage/dev-python/requests-0.12.1/work/requests-0.12.1/requests/packages/oreos/core.py", line 10, in <module>
    from .monkeys import SimpleCookie
  File "/var/tmp/portage/dev-python/requests-0.12.1/work/requests-0.12.1/requests/packages/oreos/monkeys.py", line 327, in <module>
    idmap=_idmap, translate=string.translate):
AttributeError: 'module' object has no attribute 'translate'

---

Ran 12 tests in 5.990s

(The tests work fine against 2.7.)


`make citests` runs the tests (there should be 75 of them). I'm not sure what a bare `nosetests` ends up discovering. Anyway, `oreos` is dead code in trunk, so it isn't breaking the 3.x build.

We could do a better job of documenting this. Anyway, here are the buildbots:

http://travis-ci.org/#!/kennethreitz/requests
http://ci.kennethreitz.com/job/requests/


Makefile is absent in tarball.

Minimal fix:

```
--- requests/packages/oreos/monkeys.py
+++ requests/packages/oreos/monkeys.py
@@ -324,7 +324,7 @@
 _idmap = ''.join(chr(x) for x in range(256))

 def _quote(str, LegalChars=_LegalChars,
-           idmap=_idmap, translate=string.translate):
+           idmap=_idmap, translate=str.translate):
     #
     # If the string does not need to be double-quoted,
     # then just return the string.  Otherwise, surround
@@ -462,7 +462,7 @@

     def set(self, key, val, coded_val,
             LegalChars=_LegalChars,
-            idmap=_idmap, translate=string.translate):
+            idmap=_idmap, translate=str.translate):
         # First we verify that the key isn't a reserved word
         # Second we make sure it only contains legal characters
         if key.lower() in self._reserved:
```


Really, the tests shouldn't be in the tarball either; they are not "production code".


Oh, please. Running the tests before installation is a pretty useful feature, production code or not.


I don't know how the default discovery mechanism of `nosetests` is implemented exactly, but consider this. The Requests codebase is intended to work with both Python 2 and Python 3; we implement this by means of a compatibility module (`requests.compat`) that detects the version and imports the right module depending on the version. Thus, it would be perfectly reasonable for us to package a module that fails completely under Python 3, for example, with a `SyntaxError` --- as long as that module is not imported when Python 3 is detected.

Now, the entire `oreos` module is dead code in trunk:

```
$ git grep oreos
requests/packages/oreos/core.py:oreos.core
requests/packages/oreos/monkeys.py:oreos.monkeys
requests/packages/oreos/structures.py:oreos.structure
```

so I don't know why nosetests is trying to import it. The point is that `nosetests` is not smart enough to detect which modules we intend to be Python 3 compatible.

Maybe the right thing to do would be to put `Makefile` in the tarball, and document exactly which target runs the tests that are expected to succeed under all platforms (currently `make citests`). I'll open a ticket to clarify the situation on this, but currently there is no "stable answer" (and, as discussed previously, it can't be a plain `nosetests`).

Anyway, don't you trust us to ship working code? ;-)


OK, #601.


I'm not wedded to nosetests or anything, I just want an easy way to run the tests. :) Supporting python setup.py test would also be pretty nice (via the test_suite keyword to setup()).