configconfig.testing

Helpers for testing ConfigVar.

Attention

This module has the following additional requirement:

pytest

This can be installed as follows:

python -m pip install configconfig[testing]

New in version 0.2.0.

Classes:

BoolFalseTest()

Test for boolean configuration values which default to False.

BoolTrueTest()

Test for boolean configuration values which default to True.

ConfigVarTest()

Base class for tests of ConfigVars.

DictTest()

Test for dictionary configuration values.

DirectoryTest()

Test for configuration values which represent directories.

EnumTest()

Test for Enum configuration values.

ListTest()

Test for list configuration values.

NotBoolTest()

Mixin to add tests for ConfigVars that can’t be boolean values.

NotIntTest()

Mixin to add tests for ConfigVars that can’t be integers.

NotStrTest()

Mixin to add tests for ConfigVars that can’t be strings.

OptionalStringTest()

Test for string configuration values which are optional.

RequiredStringTest()

Test for string configuration values which are required.

class ConfigVarTest[source]

Bases: ABC

Base class for tests of ConfigVars.

config_var

Type:    Type[ConfigVar]

The ConfigVar under test.

class NotIntTest[source]

Bases: ConfigVarTest

Mixin to add tests for ConfigVars that can’t be integers.

test_error_int()[source]

Checks that the ConfigVar raises a ValueError when passed an int.

class NotBoolTest[source]

Bases: ConfigVarTest

Mixin to add tests for ConfigVars that can’t be boolean values.

test_error_bool()[source]

Checks that the ConfigVar raises a ValueError when passed a bool.

class NotStrTest[source]

Bases: ConfigVarTest

Mixin to add tests for ConfigVars that can’t be strings.

test_error_str()[source]

Checks that the ConfigVar raises a ValueError when passed a str.

class ListTest[source]

Bases: NotStrTest, NotBoolTest, NotIntTest, ConfigVarTest

Test for list configuration values.

Attributes:

default_value

The default value that should be returned when no valid is given.

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_value

A value that is valid and should be returned unchanged.

Methods:

test_success()

Checks that the ConfigVar can correctly parse various list values.

default_value = []

Type:    List[str]

The default value that should be returned when no valid is given.

different_key_value = {'username': 'domdfcoding'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_success()[source]

Checks that the ConfigVar can correctly parse various list values.

test_value

Type:    List[str]

A value that is valid and should be returned unchanged.

class DirectoryTest[source]

Bases: NotBoolTest, NotIntTest, ConfigVarTest

Test for configuration values which represent directories.

Attributes:

default_value

The default value that should be returned when no valid is given.

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_value

A value that is valid and should be returned unchanged.

Methods:

test_error_list_int()

Checks that the ConfigVar raises a ValueError when passed a str.

test_error_list_str()

Checks that the ConfigVar raises a ValueError when passed a str.

test_success()

Checks that the ConfigVar can correctly parse various directory values.

default_value

Type:    str

The default value that should be returned when no valid is given.

different_key_value = {'username': 'domdfcoding'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_error_list_int()[source]

Checks that the ConfigVar raises a ValueError when passed a str.

test_error_list_str()[source]

Checks that the ConfigVar raises a ValueError when passed a str.

test_success()[source]

Checks that the ConfigVar can correctly parse various directory values.

test_value

Type:    str

A value that is valid and should be returned unchanged.

class BoolTrueTest[source]

Bases: ConfigVarTest

Test for boolean configuration values which default to True.

Attributes:

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

false_values

A list of values which should be considered False by the ConfigVar.

true_values

A list of values which should be considered True by the ConfigVar.

wrong_values

A list of values which should are of the wrong type.

Methods:

test_empty_get()

test_errors()

test_false()

test_true()

different_key_value = {'username': 'domdfcoding'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

property false_values

A list of values which should be considered False by the ConfigVar.

Return type

List[Dict[str, Any]]

test_empty_get()[source]
test_errors()[source]
test_false()[source]
test_true()[source]
property true_values

A list of values which should be considered True by the ConfigVar.

Return type

List[Dict[str, Any]]

property wrong_values

A list of values which should are of the wrong type.

Return type

List[Dict[str, Any]]

class BoolFalseTest[source]

Bases: BoolTrueTest

Test for boolean configuration values which default to False.

Attributes:

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

false_values

A list of values which should be considered False by the ConfigVar.

true_values

A list of values which should be considered True by the ConfigVar.

Methods:

test_empty_get()

different_key_value = {'username': 'domdfcoding'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

property false_values

A list of values which should be considered False by the ConfigVar.

Return type

List[Dict[str, Any]]

test_empty_get()[source]
property true_values

A list of values which should be considered True by the ConfigVar.

Return type

List[Dict[str, Any]]

class RequiredStringTest[source]

Bases: ConfigVarTest

Test for string configuration values which are required.

Methods:

test_empty_get()

test_errors()

test_success()

Attributes:

test_value

A value that is valid and should be returned unchanged.

wrong_values

A list of values which should are of the wrong type.

test_empty_get()[source]
test_errors()[source]
test_success()[source]
test_value

Type:    str

A value that is valid and should be returned unchanged.

property wrong_values

A list of values which should are of the wrong type.

Return type

List[Dict[str, Any]]

class OptionalStringTest[source]

Bases: RequiredStringTest

Test for string configuration values which are optional.

Attributes:

default_value

The default value that should be returned when no valid is given.

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

wrong_values

A list of values which should are of the wrong type.

Methods:

test_empty_get()

test_errors()

test_success()

default_value = ''

Type:    str

The default value that should be returned when no valid is given.

different_key_value = {'sphinx_html_theme': 'alabaster'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_empty_get()[source]
test_errors()[source]
test_success()[source]
property wrong_values

A list of values which should are of the wrong type.

Return type

List[Dict[str, Any]]

class EnumTest[source]

Bases: RequiredStringTest

Test for Enum configuration values.

Attributes:

default_value

The default value that should be returned when no valid is given.

non_enum_values

A list of values which are of the correct type but are invalid.

Methods:

test_empty_get()

test_errors()

test_non_enum()

default_value

Type:    str

The default value that should be returned when no valid is given.

non_enum_values

Type:    List[Any]

A list of values which are of the correct type but are invalid.

test_empty_get()[source]
test_errors()[source]
test_non_enum()[source]
class DictTest[source]

Bases: NotStrTest, NotBoolTest, NotIntTest, ConfigVarTest

Test for dictionary configuration values.

Attributes:

default_value

The default value that should be returned when no valid is given.

different_key_value

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_value

A value that is valid and should be returned unchanged.

Methods:

test_error_list_int()

test_success()

default_value = {}

Type:    Dict[str, Any]

The default value that should be returned when no valid is given.

different_key_value = {'sphinx_html_theme': 'alabaster'}

Type:    Dict[str, Any]

A dictionary containing one or more keys that are not the keys used by the ConfigVar

test_error_list_int()[source]
test_success()[source]
test_value

Type:    Dict[str, Any]

A value that is valid and should be returned unchanged.