Issue #160: Add minimize_source testcases

pull/178/head
Alex Willmer 7 years ago
parent f1e6fe007b
commit 35ae4e4227

@ -46,6 +46,7 @@ run_test tests/importer_test.py
run_test tests/latch_test.py run_test tests/latch_test.py
run_test tests/local_test.py run_test tests/local_test.py
run_test tests/master_test.py run_test tests/master_test.py
run_test tests/minimize_source_tests.py
run_test tests/module_finder_test.py run_test tests/module_finder_test.py
run_test tests/nested_test.py run_test tests/nested_test.py
run_test tests/parent_test.py run_test tests/parent_test.py

@ -0,0 +1,8 @@
class C:
"""docstring
"""
def method(self):
"""docstring
"""
pass

@ -0,0 +1,8 @@
class C:
def method(self):
pass

@ -0,0 +1,4 @@
def f():
"""docstring
"""
pass

@ -0,0 +1,3 @@
#/usr/bin/python -c
# coding: utf-8
# comment

@ -0,0 +1,3 @@
#/usr/bin/python -c
# coding: utf-8

@ -0,0 +1,5 @@
"""docstring
"""
pass

@ -0,0 +1,49 @@
#!python
# coding : utf-8
# comment
"docstring"
import sys
"cc", {}
def f1(a, b= None, c=[]): # comment
r"""docstring
"""
x = ""
print(
a,
b,
"""arg1""", # comment
"""arg2""", # comment
c )
# comment
'foo' > sys.stderr
"baz"
#comment
sys.stdout;lambda: "justastring"
1j
def f2():
# comment
'''docstring'''
pass
class c:
u'''docstring'''
f='justastring'
b'''docstring
'''
@f1
class c2(object):
'docstring'
def __init__(self):
"docstring"
def inner(): pass
d = {'a':0}
for x in '':
"justastring"

@ -0,0 +1,49 @@
#!python
# coding : utf-8
import sys
"cc", {}
def f1(a, b= None, c=[]):
x = ""
print(
a,
b,
"""arg1""",
"""arg2""",
c )
'foo' > sys.stderr
sys.stdout;lambda: "justastring"
1j
def f2():
pass
class c:
f='justastring'
@f1
class c2(object):
def __init__(self):
def inner(): pass
d = {'a':0}
for x in '':
"justastring"

@ -0,0 +1,45 @@
import unittest2
from mitogen.parent import minimize_source
import testlib
def read_sample(fname):
sample_path = testlib.data_path('minimize_samples/' + fname)
sample_file = open(sample_path)
sample = sample_file.read()
sample_file.close()
return sample
class MinimizeSource(unittest2.TestCase):
def test_class(self):
original = read_sample('class.py')
minimized = read_sample('class_min.py')
self.assertEquals(minimized, minimize_source(original))
def test_def(self):
original = read_sample('def.py')
minimized = read_sample('def_min.py')
self.assertEquals(minimized, minimize_source(original))
def test_hashbang(self):
original = read_sample('hashbang.py')
minimized = read_sample('hashbang_min.py')
self.assertEquals(minimized, minimize_source(original))
def test_mod(self):
original = read_sample('mod.py')
minimized = read_sample('mod_min.py')
self.assertEquals(minimized, minimize_source(original))
def test_obstacle_course(self):
original = read_sample('obstacle_course.py')
minimized = read_sample('obstacle_course_min.py')
self.assertEquals(minimized, minimize_source(original))
if __name__ == '__main__':
unittest2.main()
Loading…
Cancel
Save