mkwiatkowski / pythoscope

unit test generator for Python
http://pythoscope.wikidot.com
MIT License
96 stars 26 forks source link

2to3 issue #13

Open gthieleb opened 7 years ago

gthieleb commented 7 years ago
$ pythoscope --template nose common/planning.py 
ERROR: Oops, it seems that an internal Pythoscope error occurred. Please file a bug report at https://bugs.launchpad.net/pythoscope

Traceback (most recent call last):
  File "/home/user/envs/install/bin/pythoscope", line 9, in <module>
    load_entry_point('pythoscope==0.4.3', 'console_scripts', 'pythoscope')()
  File "/home/user/envs/install/local/lib/python2.7/site-packages/pythoscope/__init__.py", line 190, in main
    generate_tests(args, force, template)
  File "/home/user/envs/install/local/lib/python2.7/site-packages/pythoscope/__init__.py", line 117, in generate_tests
    project = Project.from_directory(find_project_directory(modules[0]))
  File "/home/user/envs/install/local/lib/python2.7/site-packages/pythoscope/store.py", line 69, in from_directory
    project = load_pickle_from(get_pickle_path(project_path))
  File "/home/user/envs/install/local/lib/python2.7/site-packages/pythoscope/util.py", line 365, in load_pickle_from
    obj = cPickle.load(fd)
TypeError: ('__init__() takes exactly 5 arguments (2 given)', <class 'lib2to3.pgen2.parse.ParseError'>, ("bad input: type=1, value='def', context=('\\n', (90, 0))",))
mkwiatkowski commented 7 years ago

Thank you for the report. Could you provide more context? In particular, can you pinpoint what file in your project causes this issue? Could you attach that file here?

gthieleb commented 7 years ago

TypeError raises for example with this small snippet:

#!/usr/bin/env python

import os
from pwd import getpwuid
import sys

def print_cmds(rootpath):

  for root, dirs, files in os.walk(rootpath):
    for base in (dirs + files):
      path = os.path.join(root, base)
      print "echo chown %s:%s %s" % (get_ownership(path)[0], get_ownership(path)[1], path)
      print "echo chmod %s %s" % (get_permissions(path), path)

def get_permissions(path):
  return oct(os.stat(path).st_mode & 0777)

def get_ownership(path):
  return os.stat(path).st_uid, os.stat(path).st_gid

if __name__ == '__main__':
  print_cmds(sys.argv[1])
~                           
goulu commented 7 years ago

Solved with my PR https://github.com/mkwiatkowski/pythoscope/pull/14 (or my branch) which uses six instead of lib2to3