tests.unit.test_grouptheory   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 15

7 Functions

Rating   Name   Duplication   Size   Complexity  
A test_multiplicative_order_bad_a_n_not_coprime() 0 4 2
A test_multiplicative_order_bad_a_type_str() 0 6 2
A test_multiplicative_order_bad_n_type_str() 0 6 2
A test_multiplicative_order_bad_n_zero() 0 5 2
A test_multiplicative_order_bad_n_type_float() 0 6 2
A test_multiplicative_order_correctness() 0 14 3
A test_multiplicative_order_bad_a_type_float() 0 6 2
1
"""
2
:mod:`tests.unit.test_grouptheory` -- Unit Tests
3
================================================
4
5
.. module:: tests.unit.test_grouptheory
6
   :synopsis: Unit tests for the lib.grouptheory module.
7
8
.. moduleauthor:: Bill Maroney <[email protected]>
9
"""
10
11
import pytest
12
13
from lib.grouptheory import multiplicative_order
14
15
16
@pytest.mark.parametrize("a,n,order", [(2, 7, 3), (10, 99, 2), (937, 9008, 562), (2, 11111111111, 6158856)])
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
17
def test_multiplicative_order_correctness(a: int, n: int, order: int):
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_correctness does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name a does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
The name n does not conform to the argument naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
18
    """ Test the correctness of :func:`lib.grouptheory.multiplicative_order` using known answer tests
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
19
20
    :param a: the base input value
21
    :param n: the modulus defining the multiplicative group
22
    :param order: the expected answer, i.e. :math:`ord_n(a)`
23
    :raises AssertionError: if :func:`lib.grouptheory.multiplicative_order` returns the wrong type
24
    :raises AssertionError: if :func:`lib.grouptheory.multiplicative_order` returns the wrong value
25
    """
26
27
    computed_answer = multiplicative_order(a, n)
28
    assert isinstance(computed_answer, multiplicative_order.__annotations__["return"]), "wrong type"
29
    assert computed_answer == order, "wrong answer"
30
31
32
def test_multiplicative_order_bad_a_type_str():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_a_type_str does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
33
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``TypeError`` for a non-``int`` value for `a`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
34
    (``str``)
35
    """
36
    with pytest.raises(TypeError):
37
        multiplicative_order("123", 10)
38
39
40
def test_multiplicative_order_bad_a_type_float():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_a_type_float does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
41
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``TypeError`` for a non-``int`` value for `a`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
42
    (``float``)
43
    """
44
    with pytest.raises(TypeError):
45
        multiplicative_order(123.0, 10)
46
47
48
def test_multiplicative_order_bad_n_type_str():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_n_type_str does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
49
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``TypeError`` for a non-``int`` value for `n`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
50
    (``str``)
51
    """
52
    with pytest.raises(TypeError):
53
        multiplicative_order(2, "123")
54
55
56
def test_multiplicative_order_bad_n_type_float():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_n_type_float does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
57
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``TypeError`` for a non-``int`` value for `n`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (117/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
58
    (``float``)
59
    """
60
    with pytest.raises(TypeError):
61
        multiplicative_order(2, 123.0)
62
63
64
def test_multiplicative_order_bad_n_zero():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_n_zero does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
65
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``ValueError`` for a non-positive value for `n`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
66
    """
67
    with pytest.raises(ValueError):
68
        multiplicative_order(2, 0)
69
70
71
def test_multiplicative_order_bad_a_n_not_coprime():
0 ignored issues
show
Coding Style Naming introduced by
The name test_multiplicative_order_bad_a_n_not_coprime does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
72
    """ Test that :func:`lib.grouptheory.multiplicative_order` raises a ``ValueError`` for non co-prime `a,n` """
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
73
    with pytest.raises(ValueError):
74
        multiplicative_order(2, 4)
75