Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 991a52e

Browse files
committed
gentest: 4-spaces -> 2-spaces
1 parent 63b87f7 commit 991a52e

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

tools/gentest

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,70 +30,70 @@ parser.add_argument('-modname', help='Module to generate a _test.go file to', re
3030

3131

3232
template = textwrap.dedent("""
33-
package %s
34-
import (
35-
"os"
36-
"grumpy"
37-
%s
38-
)
39-
func TestRunCode(t *testing.T) {
40-
grumpy.ImportModule(grumpy.NewRootFrame(), "traceback")
41-
if grumpy.RunMain(Code) != 0 {
42-
t.Fail()
43-
}
44-
}
33+
package %s
34+
import (
35+
\t"os"
36+
\t"grumpy"
37+
\t%s
38+
)
39+
func TestRunCode(t *testing.T) {
40+
\tgrumpy.ImportModule(grumpy.NewRootFrame(), "traceback")
41+
\tif grumpy.RunMain(Code) != 0 {
42+
\t\tt.Fail()
43+
\t}
44+
}
4545
""")
4646

4747

4848
def _package_name(modname):
49-
if modname.startswith('__go__/'):
50-
return '__python__/' + modname
51-
return '__python__/' + modname.replace('.', '/')
49+
if modname.startswith('__go__/'):
50+
return '__python__/' + modname
51+
return '__python__/' + modname.replace('.', '/')
5252

5353

5454
def _get_gopath():
55-
gopath = os.getenv('GOPATH', None)
56-
if not gopath:
57-
print >> sys.stderr, 'GOPATH not set'
58-
raise RuntimeError('GOPATH not set')
59-
return gopath
55+
gopath = os.getenv('GOPATH', None)
56+
if not gopath:
57+
print >> sys.stderr, 'GOPATH not set'
58+
raise RuntimeError('GOPATH not set')
59+
return gopath
6060

6161

6262
def main(args):
63-
modname = args.modname
64-
gopath = _get_gopath()
65-
workdir = 'build' # It is ok _right now_
66-
py_dir = os.path.join(workdir, 'src', '__python__')
67-
mod_dir = os.path.join(py_dir, modname)
63+
modname = args.modname
64+
gopath = _get_gopath()
65+
workdir = 'build' # It is ok _right now_
66+
py_dir = os.path.join(workdir, 'src', '__python__')
67+
mod_dir = os.path.join(py_dir, modname)
6868

69-
script = os.path.join(py_dir, '%s.py' % modname)
70-
gopath = gopath + os.pathsep + workdir
71-
package = _package_name(modname)
69+
script = os.path.join(py_dir, '%s.py' % modname)
70+
gopath = gopath + os.pathsep + workdir
71+
package = _package_name(modname)
7272

73-
if not os.path.isfile(script):
74-
return # The script does not exist. And is OK!
73+
if not os.path.isfile(script):
74+
return # The script does not exist. And is OK!
7575

76-
names = imputil.calculate_transitive_deps(modname, script, gopath)
76+
names = imputil.calculate_transitive_deps(modname, script, gopath)
7777

78-
# Find the script associated with the given module.
79-
for d in gopath.split(os.pathsep):
80-
script = imputil.find_script(
81-
os.path.join(d, 'src', '__python__'), modname)
82-
if script:
83-
break
84-
else:
85-
raise RuntimeError("can't find module %s", modname)
78+
# Find the script associated with the given module.
79+
for d in gopath.split(os.pathsep):
80+
script = imputil.find_script(
81+
os.path.join(d, 'src', '__python__'), modname)
82+
if script:
83+
break
84+
else:
85+
raise RuntimeError("can't find module %s", modname)
8686

87-
names = imputil.calculate_transitive_deps(modname, script, gopath)
88-
# Make sure traceback is available in all Python binaries.
89-
names.add('traceback')
87+
names = imputil.calculate_transitive_deps(modname, script, gopath)
88+
# Make sure traceback is available in all Python binaries.
89+
names.add('traceback')
9090

91-
imports = '\n '.join('"%s"' % _package_name(name) for name in names)
91+
imports = '\n\t'.join('"%s"' % _package_name(name) for name in names)
9292

93-
testfile_contents = template % (modname, imports)
94-
with open(os.path.join(mod_dir, 'module_test.go'), 'w') as go_testfile:
95-
go_testfile.write(testfile_contents)
93+
testfile_contents = template % (modname, imports)
94+
with open(os.path.join(mod_dir, 'module_test.go'), 'w') as go_testfile:
95+
go_testfile.write(testfile_contents)
9696

9797

9898
if __name__ == '__main__':
99-
sys.exit(main(parser.parse_args()))
99+
sys.exit(main(parser.parse_args()))

0 commit comments

Comments
 (0)