Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
b6e70427
Commit
b6e70427
authored
May 09, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding RSF base class extending unittest.TestCase functionality.
parent
a098d4c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
3 deletions
+47
-3
__init__.py
routersploit/test/__init__.py
+2
-1
test_case.py
routersploit/test/test_case.py
+25
-0
utils.py
routersploit/utils.py
+20
-2
No files found.
routersploit/test/__init__.py
View file @
b6e70427
__author__
=
'fwkz'
from
routersploit.test.test_case
import
RoutersploitTestCase
\ No newline at end of file
routersploit/test/test_case.py
0 → 100644
View file @
b6e70427
import
unittest
from
routersploit.utils
import
NonStringIterable
class
RoutersploitTestCase
(
unittest
.
TestCase
):
def
assertIsDecorated
(
self
,
function
,
decorator_name
):
try
:
decorator_list
=
function
.
__decorators__
except
AttributeError
:
decorator_list
=
[]
self
.
assertIn
(
decorator_name
,
decorator_list
,
msg
=
"'{}' method should be decorated with 'module_required'"
.
format
(
function
.
__name__
)
)
def
assertIsSequence
(
self
,
arg
):
self
.
assertEqual
(
True
,
isinstance
(
arg
,
NonStringIterable
),
"'{}' is not a sequence"
.
format
(
arg
)
)
\ No newline at end of file
routersploit/utils.py
View file @
b6e70427
from
__future__
import
print_function
from
__future__
import
absolute_import
import
threading
import
os
import
sys
import
random
import
string
import
socket
import
importlib
from
functools
import
wraps
from
distutils.util
import
strtobool
import
importlib
from
abc
import
ABCMeta
,
abstractmethod
import
requests
from
.exceptions
import
RoutersploitException
from
.
import
modules
as
rsf_modules
MODULES_DIR
=
rsf_modules
.
__path__
[
0
]
print_lock
=
threading
.
Lock
()
...
...
@@ -256,6 +257,23 @@ class LockedIterator(object):
self
.
lock
.
release
()
class
NonStringIterable
:
__metaclass__
=
ABCMeta
@abstractmethod
def
__iter__
(
self
):
while
False
:
yield
None
@classmethod
def
__subclasshook__
(
cls
,
C
):
if
cls
is
NonStringIterable
:
if
any
(
"__iter__"
in
B
.
__dict__
for
B
in
C
.
__mro__
):
return
True
return
NotImplemented
def
print_table
(
headers
,
*
args
,
**
kwargs
):
""" Print table.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment