# Path: py3kwarn/main.py
# def main(args=None):
#     if args is None:
#         args = sys.argv[1:]
# 
#     import optparse
#     parser = optparse.OptionParser(version='%prog {0}'.format(__version__),
#                                    prog='py3kwarn')
#     parser.add_option('-j', '--jobs', action='store', default=1,
#                       type='int', help='Run in parallel')
#     options, args = parser.parse_args(args)
# 
#     if options.jobs < 1:
#         try:
#             import multiprocessing
#         except ImportError:
#             parser.error('"--jobs" is not supported on this platform')
#         options.jobs = multiprocessing.cpu_count()
# 
#     return 2 if print_warnings_for_files(args,
#                                          num_processes=options.jobs) else 0


import os
import unittest
from py3kwarn import main
code_callable = "callable('hello')"
code_dict = """
d.keys()
d.iteritems()
d.viewvalues()
"""
code_except = """
try:
    import asdf
except E, T:
    pass
"""
code_exec = 'exec code in ns1, ns2'
code_execfile = "execfile('test.py')"
code_filter = 'filter(lambda x: x, [1, 2, 3])'
code_funcattrs = """
def test():
    pass
test.func_name
test.func_closure
test.func_dict
"""
code_has_key = "d.has_key('foobar')"

code_unicode = "ur'Hello World'"


class TestPy3kWarn(unittest.TestCase):

    def _test_code(self, name, casename=None):

# Path: py3kwarn/main.py
# def main(args=None):
#     if args is None:
#         args = sys.argv[1:]
# 
#     import optparse
#     parser = optparse.OptionParser(version='%prog {0}'.format(__version__),
#                                    prog='py3kwarn')
#     parser.add_option('-j', '--jobs', action='store', default=1,
#                       type='int', help='Run in parallel')
#     options, args = parser.parse_args(args)
# 
#     if options.jobs < 1:
#         try:
#             import multiprocessing
#         except ImportError:
#             parser.error('"--jobs" is not supported on this platform')
#         options.jobs = multiprocessing.cpu_count()
# 
#     return 2 if print_warnings_for_files(args,
#                                          num_processes=options.jobs) else 0


# Path: py3kwarn/tests.py
import os
import unittest
from py3kwarn import main

code_callable = "callable('hello')"
code_dict = """
d.keys()
d.iteritems()
d.viewvalues()
"""
code_except = """
try:
    import asdf
except E, T:
    pass
"""
code_exec = 'exec code in ns1, ns2'
code_execfile = "execfile('test.py')"
code_filter = 'filter(lambda x: x, [1, 2, 3])'
code_funcattrs = """
def test():
    pass
test.func_name
test.func_closure
test.func_dict
"""
code_has_key = "d.has_key('foobar')"

code_unicode = "ur'Hello World'"


class TestPy3kWarn(unittest.TestCase):

    def _test_code(self, name, casename=None):

        warnings = main.warnings_for_string(globals()['code_' + name], name)