Commit b6e70427 by fwkz

Adding RSF base class extending unittest.TestCase functionality.

parent a098d4c5
__author__ = 'fwkz'
from routersploit.test.test_case import RoutersploitTestCase
\ No newline at end of file
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
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment