Skip to content

Commit

Permalink
format code style - pep8-naming
Browse files Browse the repository at this point in the history
  • Loading branch information
tp7309 committed Jan 27, 2018
1 parent e432b4e commit 010470d
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 218 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ universal=1

[flake8]
#line too long
ignore = E501
ignore = E501,W503,E251
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,.vscode
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
author_email='[email protected]',
url='https://github.com/tp7309/TTPassGen',
license='Apache License Version 2.0',
keywords='python ttpassgen password-generator wordlist password-dict password-dict-generator brute-force word-combination',
keywords=
'python ttpassgen password-generator wordlist password-dict password-dict-generator brute-force word-combination',
long_description=long_description,
packages=find_packages(exclude=['docs', 'tests*']),
include_package_data=True,
Expand Down
43 changes: 20 additions & 23 deletions tests/test_TTPassGen.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding: utf-8

from __future__ import print_function
from ttpassgen import ttpassgen
import unittest
import os
import sys
myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath + '/../')
from ttpassgen import ttpassgen

tests_path = os.path.dirname(os.path.abspath(__file__))


# tests/in.dict generate by: ttpassgen -r [123]{3} in.dict
Expand All @@ -25,7 +24,7 @@ def lc_func():
lc = lc_func

def go_func(rule,
dictlist=os.path.join(myPath, 'in.dict'),
dictlist=os.path.join(tests_path, 'in.dict'),
mode=0,
partSize=0,
diskCache=500,
Expand All @@ -48,8 +47,6 @@ def go_func(rule,
@classmethod
def tearDownClass(cls):
super(Test_ttpassgen, cls).tearDownClass()
lc = None
go = None
if os.path.exists('testout.dict'):
os.remove('testout.dict')
if os.path.exists('testout.dict.1'):
Expand Down Expand Up @@ -121,15 +118,15 @@ def test_word_seperator(self):
go('$0[abc]?', seperator='-------------------------\n'), 24)

def test_multi_dict_mark_charset_rule(self):
inDict = os.path.join(myPath, 'in.dict')
in2Dict = os.path.join(myPath, 'in2.dict')
with open(in2Dict, 'wb') as f:
dict_in = os.path.join(tests_path, 'in.dict')
dict_in2 = os.path.join(tests_path, 'in2.dict')
with open(dict_in2, 'wb') as f:
content = ['q00', 'q01']
f.write(('\n'.join(content)).encode('utf-8'))
self.assertEquals(
go('$1$0[abc]?', dictlist="%s,%s" % (inDict, in2Dict)), 48)
if os.path.exists(in2Dict):
os.remove(in2Dict)
go('$1$0[abc]?', dictlist="%s,%s" % (dict_in, dict_in2)), 48)
if os.path.exists(dict_in2):
os.remove(dict_in2)

def test_part_size_with_complex_rule(self):
if os.path.exists('testout.dict.1'):
Expand All @@ -140,13 +137,13 @@ def test_part_size_with_complex_rule(self):
os.remove('testout.dict.3')

go('[?d]{1:4:*}$0[?q]$[0123]', partSize=1, debugMode=1)
totalLine = 0
total_line = 0
with open('testout.dict.1', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())
with open('testout.dict.2', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())
with open('testout.dict.3', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())

# actual value: 1024 * 1, why 24 difference? I like do it>_>
self.assertTrue(
Expand All @@ -157,7 +154,7 @@ def test_part_size_with_complex_rule(self):
os.remove('testout.dict.2')
if os.path.exists('testout.dict.3'):
os.remove('testout.dict.3')
self.assertEquals(totalLine, 266640)
self.assertEquals(total_line, 266640)

def test_multiprocessing_complex_rule(self):
self.assertEquals(go('[789]{0:3:*}$0[?q]$0', debugMode=0), 1440)
Expand All @@ -175,14 +172,14 @@ def test_part_size(self):
os.remove('testout.dict.3')

go('[?l]{1:4}', partSize=1)
totalLine = 0
total_line = 0
with open('testout.dict.1', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())
with open('testout.dict.2', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())
if len(os.linesep) > 1:
with open('testout.dict.3', 'r') as f:
totalLine += len(f.readlines())
total_line += len(f.readlines())

# actual value: 1024 * 1, why 24 difference? I like do it>_>
self.assertTrue(
Expand All @@ -193,7 +190,7 @@ def test_part_size(self):
os.remove('testout.dict.2')
if os.path.exists('testout.dict.3'):
os.remove('testout.dict.3')
self.assertEquals(totalLine, 375076)
self.assertEquals(total_line, 375076)

def test_wrong_length_in_rule(self):
if os.path.exists('testout.dict'):
Expand Down
Loading

0 comments on commit 010470d

Please sign in to comment.