tests.unit.test_sequence Module

This module contains all unit tests for the lib.sequence module.

tests.unit.test_sequence – Unit Tests

tests.unit.test_sequence.test_continued_fraction()

FIXME: unit tests still to be defined

tests.unit.test_sequence.test_divisors_bad_n_type_float()

Test that lib.sequence.Divisors raises a TypeError for a non-int value for n (float)

tests.unit.test_sequence.test_divisors_bad_n_type_str()

Test that lib.sequence.Divisors raises a TypeError for a non-int value for n (str)

tests.unit.test_sequence.test_divisors_bad_n_zero()

Test that lib.sequence.Divisors raises a ValueError for \(\mbox{n} = 0\)

tests.unit.test_sequence.test_divisors_bad_proper_type_float()

Test that lib.sequence.Divisors raises a TypeError for a non-bool value for proper (float)

tests.unit.test_sequence.test_divisors_bad_proper_type_str()

Test that lib.sequence.Divisors raises a TypeError for a non-bool value for proper (str)

tests.unit.test_sequence.test_divisors_correctness(n, proper, expected_answer)

Test the correctness of lib.sequence.Divisors using known answer tests

Parameters:
  • n (int) – the input value
  • proper (bool) – whether to only consider proper divisors or not
  • expected_answer (Set[int]) – the expected answer
Raises:
tests.unit.test_sequence.test_divisors_correctness_in(n, proper, d, expected_answer)

Test the correctness of membership tests for lib.sequence.Divisors instances using known answer tests

Parameters:
  • n (int) – the input value
  • proper (bool) – whether to only consider proper divisors or not
  • d (int) – the input divisor
  • expected_answer (bool) – whether \(d\) is a [proper] divisor of \(n\)
Raises:
tests.unit.test_sequence.test_divisors_correctness_len(n, n_divisors)

Test the correctness of length calculations of lib.sequence.Divisors instances using known answer tests

Parameters:
  • n (int) – the input value
  • n_divisors (int) – the expected number of divisors (all, not proper)
Raises:
tests.unit.test_sequence.test_divisors_in_bad_item_type_str()

Test that lib.sequence.Divisors raises a TypeError for a non-int value for item (str)

tests.unit.test_sequence.test_divisorsrange_bad_proper_type_float()

Test that lib.sequence.DivisorsRange raises a TypeError for a non-bool value for proper (float)

tests.unit.test_sequence.test_divisorsrange_bad_proper_type_str()

Test that lib.sequence.DivisorsRange raises a TypeError for a non-bool value for proper (str)

tests.unit.test_sequence.test_divisorsrange_bad_upper_bound_type_float()

Test that lib.sequence.DivisorsRange raises a TypeError for a non-int value for upper_bound (float)

tests.unit.test_sequence.test_divisorsrange_bad_upper_bound_type_str()

Test that lib.sequence.DivisorsRange raises a TypeError for a non-int value for upper_bound (str)

tests.unit.test_sequence.test_divisorsrange_bad_upper_bound_zero()

Test that lib.sequence.DivisorsRange raises a ValueError for \(upper\_bound = 0\)

tests.unit.test_sequence.test_divisorsrange_correctness(proper)

Test the correctness of lib.sequence.DivisorsRange using known answer tests

The divisors yielded by this sieve are tested to ensure that they do divide the given integer \(n\), up to some moderate bound on \(n\). Additionally, it is checked that \(1\) is included as a proper divisor of \(n\) and that \(n\) is not.

Parameters:

proper (bool) – whether to only consider proper divisors or not

Raises:
tests.unit.test_sequence.test_factorials_correctness_batch()

Test the correctness of lib.sequence.Factorials using known data

tests.unit.test_sequence.test_factorials_correctness_getitem(n, n_factorial)

Test the correctness of indexing lib.sequence.Factorials instances using known answer tests

Parameters:
  • n (int) – the input value
  • n_factorial (int) – the expected answer
Raises:
tests.unit.test_sequence.test_factorials_correctness_in(x, is_factorial)

Test the correctness of membership tests for lib.sequence.Factorials instances using known answer tests

Parameters:
  • x (int) – the input value
  • is_factorial (bool) – whether \(x = N!\) \(\exists N \in \mathbb{N}\) (i.e. \(x\) is factorial)
Raises:
tests.unit.test_sequence.test_factorials_getitem_bad_item_negative()

Test that lib.sequence.Factorials raises a ValueError for an index \(\mbox{item} \lt 0\)

tests.unit.test_sequence.test_factorials_getitem_bad_item_type_float()

Test that lib.sequence.Factorials raises a TypeError for a non-int value for an index item (float)

tests.unit.test_sequence.test_factorials_getitem_bad_item_type_str()

Test that lib.sequence.Factorials raises a TypeError for a non-int value for an index item (str)

tests.unit.test_sequence.test_factorials_in_bad_item_type_str()

Test that lib.sequence.Factorials raises a TypeError for a non-int value for x (str)

tests.unit.test_sequence.test_factorials_len()

Test that len of lib.sequence.Factorials instances raises a TypeError

tests.unit.test_sequence.test_fibonaccis_correctness_batch()

Test the correctness of lib.sequence.Fibonaccis using known data

tests.unit.test_sequence.test_fibonaccis_correctness_getitem(n, nth_fibonacci)

Test the correctness of lib.sequence.Fibonaccis using known answer tests

Parameters:
  • n (int) – the input value
  • nth_fibonacci (int) – the expected answer
Raises:
tests.unit.test_sequence.test_fibonaccis_correctness_in(x, is_fibonacci)

Test the correctness of membership tests for lib.sequence.Fibonaccis instances using known answer tests

Parameters:
  • x (int) – the input value
  • is_fibonacci (bool) – whether \(x\) is a Fibonacci number or not
Raises:
tests.unit.test_sequence.test_fibonaccis_getitem_bad_item_negative()

Test that lib.sequence.Fibonaccis raises a ValueError for an index \(\mbox{item} \lt 0\)

tests.unit.test_sequence.test_fibonaccis_getitem_bad_item_type_float()

Test that lib.sequence.Fibonaccis raises a TypeError for a non-int value for an index item (float)

tests.unit.test_sequence.test_fibonaccis_getitem_bad_item_type_str()

Test that lib.sequence.Fibonaccis raises a TypeError for a non-int value for an index item (str)

tests.unit.test_sequence.test_fibonaccis_in_bad_item_type_str()

Test that lib.sequence.Fibonaccis raises a TypeError for a non-int value for x (str)

tests.unit.test_sequence.test_fibonaccis_len()

Test that len of lib.sequence.Fibonaccis instances raises a TypeError

tests.unit.test_sequence.test_figurates_in()

Test that membership tests for lib.sequence.Figurates instances raises a NotImplementedError

tests.unit.test_sequence.test_figurates_len()

Test that len of lib.sequence.Figurates instances raises a TypeError

tests.unit.test_sequence.test_figurates_next()

Test that iteration over lib.sequence.Figurates instances raises a NotImplementedError

tests.unit.test_sequence.test_hexagonals_correctness_getitem(n, nth_hexagonal)

Test the correctness of lib.sequence.Hexagonals using known answer tests

Parameters:
  • n (int) – the input value
  • nth_hexagonal (int) – the expected answer
Raises:
tests.unit.test_sequence.test_hexagonals_correctness_in(x, expected_answer)

Test the correctness of membership tests for lib.sequence.Hexagonals instances using known answer tests

Parameters:
  • x (int) – the input value
  • expected_answer (bool) – whether \(x\) is a hexagonal number or not
Raises:
tests.unit.test_sequence.test_hexagonals_correctness_iter()

Test the correctness of iteration over lib.sequence.Hexagonals instances using known answer tests

Raises:
tests.unit.test_sequence.test_hexagonals_getitem_bad_item_type_float()

Test that lib.sequence.Hexagonals raises a TypeError for a non-int value for an index item (float)

tests.unit.test_sequence.test_hexagonals_getitem_bad_item_type_str()

Test that lib.sequence.Hexagonals raises a TypeError for a non-int value for an index item (str)

tests.unit.test_sequence.test_hexagonals_in_bad_item_type_float()

Test that membership tests for lib.sequence.Hexagonals instances raise a TypeError for a non-int value (float)

tests.unit.test_sequence.test_hexagonals_in_bad_item_type_str()

Test that membership tests for lib.sequence.Hexagonals instances raise a TypeError for a non-int value (str)

tests.unit.test_sequence.test_hexagonals_len()

Test that len of lib.sequence.Hexagonals instances raises a TypeError

tests.unit.test_sequence.test_pandigitals_bad_n_negative()

Test that lib.sequence.Pandigitals raises a ValueError for \(\mbox{n} \lt 0\)

tests.unit.test_sequence.test_pandigitals_bad_n_type_float()

Test that lib.sequence.Pandigitals raises a TypeError for a non-int value for n (float)

tests.unit.test_sequence.test_pandigitals_bad_n_type_str()

Test that lib.sequence.Pandigitals raises a TypeError for a non-int value for n (str)

tests.unit.test_sequence.test_pandigitals_correctness(n, n_pandigitals)

Test the correctness of lib.sequence.Pandigitals using known answer tests

Parameters:
  • n (int) – the input value
  • n_pandigitals (Set[int]) – the expected answer
Raises:
tests.unit.test_sequence.test_pandigitals_correctness_len(n, n_pandigitals)

Test the correctness of length calculations of lib.sequence.Pandigitals instances using known answer tests

Parameters:
  • n (int) – the input value
  • n_pandigitals (Set[int]) – the expected number of \(n\)-pandigitals
Raises:

AssertionError – if lib.sequence.Pandigitals produces the wrong value

tests.unit.test_sequence.test_pentagonals_correctness_getitem(n, nth_pentagonal)

Test the correctness of lib.sequence.Pentagonals using known answer tests

Parameters:
  • n (int) – the input value
  • nth_pentagonal (int) – the expected answer
Raises:
tests.unit.test_sequence.test_pentagonals_correctness_in(x, expected_answer)

Test the correctness of membership tests for lib.sequence.Pentagonals instances using known answer tests

Parameters:
  • x (int) – the input value
  • expected_answer (bool) – whether \(x\) is a pentagonal number or not
Raises:
tests.unit.test_sequence.test_pentagonals_correctness_iter()

Test the correctness of iteration over lib.sequence.Pentagonals instances using known answer tests

Raises:
tests.unit.test_sequence.test_pentagonals_getitem_bad_item_type_float()

Test that lib.sequence.Pentagonals raises a TypeError for a non-int value for an index item (float)

tests.unit.test_sequence.test_pentagonals_getitem_bad_item_type_str()

Test that lib.sequence.Pentagonals raises a TypeError for a non-int value for an index item (str)

tests.unit.test_sequence.test_pentagonals_in_bad_item_type_float()

Test that membership tests for lib.sequence.Pentagonals instances raise a TypeError for a non-int value (float)

tests.unit.test_sequence.test_pentagonals_in_bad_item_type_str()

Test that membership tests for lib.sequence.Pentagonals instances raise a TypeError for a non-int value (str)

tests.unit.test_sequence.test_pentagonals_len()

Test that len of lib.sequence.Pentagonals instances raises a TypeError

tests.unit.test_sequence.test_primes_bad_n_primes_float()

Test that lib.sequence.Primes() raises a TypeError for a non-int value for n_primes (float)

tests.unit.test_sequence.test_primes_bad_n_primes_negative()

Test that lib.sequence.Primes() raises a ValueError for \(\mbox{n_primes} \lt 0\)

tests.unit.test_sequence.test_primes_bad_n_primes_str()

Test that lib.sequence.Primes() raises a TypeError for a non-int value for n_primes (str)

tests.unit.test_sequence.test_primes_bad_upper_bound_float()

Test that lib.sequence.Primes() raises a TypeError for a non-int value for upper_bound (float)

tests.unit.test_sequence.test_primes_bad_upper_bound_str()

Test that lib.sequence.Primes() raises a TypeError for a non-int value for upper_bound (str)

tests.unit.test_sequence.test_primes_bad_upper_bound_zero()

Test that lib.sequence.Primes() raises a ValueError for \(\mbox{upper_bound} = 0\)

tests.unit.test_sequence.test_primes_correctness_batch()

Test the correctness of lib.sequence.Primes using known data

tests.unit.test_sequence.test_primes_correctness_n_primes()

Test the correctness of lib.sequence.Primes (with n_primes) using known answer tests

tests.unit.test_sequence.test_primes_correctness_n_primes_edge_case()

Test the edge case where the estimate for \(p_n\) based on n_primes doesn’t hold (\(n \le 3\))

tests.unit.test_sequence.test_primes_correctness_n_primes_iter()

Test the correctness of iteration over lib.sequence.Primes (with n_primes) using known answer tests

Raises:
tests.unit.test_sequence.test_primes_correctness_upper_bound()

Test the correctness of lib.sequence.Primes (with upper_bound) using known answer tests

tests.unit.test_sequence.test_primes_correctness_upper_bound_iter()

Test the correctness of iteration over lib.sequence.Primes (with upper_bound) using known answer tests

Raises:
tests.unit.test_sequence.test_primes_len()

Test that len of lib.sequence.Primes instances raises a TypeError

tests.unit.test_sequence.test_sqrt_expansion()

FIXME: unit tests still to be defined

tests.unit.test_sequence.test_triangulars_correctness_getitem(n, nth_triangular)

Test the correctness of lib.sequence.Triangulars using known answer tests

Parameters:
  • n (int) – the input value
  • nth_triangular (int) – the expected answer
Raises:
tests.unit.test_sequence.test_triangulars_correctness_in(x, expected_answer)

Test the correctness of membership tests for lib.sequence.Triangulars instances using known answer tests

Parameters:
  • x (int) – the input value
  • expected_answer (bool) – whether \(x\) is a triangular number or not
Raises:
tests.unit.test_sequence.test_triangulars_correctness_iter()

Test the correctness of iteration over lib.sequence.Triangulars instances using known answer tests

Raises:
tests.unit.test_sequence.test_triangulars_getitem_bad_item_type_float()

Test that lib.sequence.Triangulars raises a TypeError for a non-int value for an index item (float)

tests.unit.test_sequence.test_triangulars_getitem_bad_item_type_str()

Test that lib.sequence.Triangulars raises a TypeError for a non-int value for an index item (str)

tests.unit.test_sequence.test_triangulars_in_bad_item_type_float()

Test that membership tests for lib.sequence.Triangulars instances raise a TypeError for a non-int value (float)

tests.unit.test_sequence.test_triangulars_in_bad_item_type_str()

Test that membership tests for lib.sequence.Triangulars instances raise a TypeError for a non-int value (str)

tests.unit.test_sequence.test_triangulars_len()

Test that len of lib.sequence.Triangulars instances raises a TypeError