How to use the parameterized.parameterized_class function in parameterized

To help you get started, we’ve selected a few parameterized examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xzkostyan / clickhouse-sqlalchemy / tests / util.py View on Github external
def mock_object_attr(dialect, attr, new_value):
    old_value = getattr(dialect, attr)
    setattr(dialect, attr, new_value)

    try:
        yield
    finally:
        setattr(dialect, attr, old_value)


def class_name_func(cls, num, params_dict):
    suffix = 'HTTP' if params_dict['session'] is http_session else 'Native'
    return cls.__name__ + suffix


with_native_and_http_sessions = parameterized_class([
    {'session': http_session},
    {'session': native_session}
], class_name_func=class_name_func)
github couchbase / couchbase-python-client / couchbase_tests / base.py View on Github external
return V3Bucket(*args, username="default", **kwargs).default_collection()
    def setUp(self, **kwargs):
        super(ClusterTestCase, self).setUp()
        connargs = self.cluster_info.make_connargs()
        connstr_abstract = ConnectionString.parse(connargs.pop('connection_string'))
        bucket_name = connstr_abstract.bucket
        connstr_abstract.bucket = None
        connstr_abstract.set_option('enable_collections', 'true')
        self.cluster = self.cluster_factory(connstr_abstract, ClusterOptions(
            ClassicAuthenticator(self.cluster_info.admin_username, self.cluster_info.admin_password)))  # type: Cluster
        # self.admin = self.cluster.admin#self.make_admin_connection()
        self.bucket = self.cluster.bucket(bucket_name, **connargs)
        self.bucket_name = bucket_name


ParamClusterTestCase = parameterized_class(('cluster_factory',), [(Cluster,), (Cluster.connect,)])(ClusterTestCase)


def skip_if_no_collections(func):
  @wraps(func)
  def wrap(self, *args, **kwargs):
    if not self.supports_collections():
      raise SkipTest('collections not supported (server < 6.5?)')
    func(self, *args, **kwargs)
  return wrap

class CollectionTestCase(ClusterTestCase):
    coll = None  # type: CBCollection
    initialised = defaultdict(lambda: {})

    def __init__(self, *args, **kwargs):
        super(CollectionTestCase, self).__init__(*args, **kwargs)
github SeldomQA / seldom / seldom / testdata / parameterized.py View on Github external
def ddt_class(attrs, input_values):
    """
    Parameterizes a test class by setting attributes on the class.
    """
    return parameterized_class(attrs, input_values)
github shoebot / shoebot / tests / unittests / test_example_bots.py View on Github external
import unittest

from parameterized import parameterized, parameterized_class

from tests.unittests.helpers import ShoebotTestCase, shoebot_named_testclass


@parameterized_class(
    [{"windowed": False}, {"windowed": True}], class_name_func=shoebot_named_testclass
)
class TestExampleOutput(ShoebotTestCase):
    windowed = False  # False for headless, True for GUI

    """
    Tests thst run examples.

    Where we are lacking bots to test features, running an existing example
    can work to excersize an API.

    Be mindful this can be expensive (in CPU, Memory and time), before adding
    examples.
    """
    @parameterized.expand(
        [
github shoebot / shoebot / tests / unittests / test_file_outputs.py View on Github external
Check if shoebot can create files in it's supported output formats
and that none are zero bytes long.
"""
import tempfile
import unittest

from parameterized import parameterized, parameterized_class

from tests.unittests.helpers import (
    ShoebotTestCase,
    shoebot_named_testclass,
    shoebot_named_testfunction,
)


@parameterized_class(
    [{"windowed": False}, {"windowed": True}], class_name_func=shoebot_named_testclass
)
class TestOutputFormats(ShoebotTestCase):
    windowed = False  # False for headless, True for GUI

    @parameterized.expand(
        ["png", "ps", "pdf", "svg"], name_func=shoebot_named_testfunction
    )
    def test_output_formats(self, file_format):
        """
        Run a simple bot for each supported output format and verify the output.
        """
        with tempfile.NamedTemporaryFile(suffix=f".{file_format}") as f:
            self.run_code("background(0)", outputfile=f.name, windowed=self.windowed)

            self.assertFileSize(f.name)