def test_hashible_of_dna_class(): try: print(set(MyDNA("atgc"))) print({MyDNA("atgc"): "smt"}) except TypeError: raise pytest.fail("in hash dna test")
def test_iterable_of_dna_class(value, expected_result): dna = MyDNA(value) actual_result = [nucl for nucl in dna] assert expected_result == actual_result
def test_incorrect_transcribe_method_of_dna_class_with_wrong_param(value): with pytest.raises(TypeError, match="coding should be True or False"): MyDNA("atgc").transcribe(value)
def test_correct_template_transcribe_method_of_dna_class( value, expected_result): dna = MyDNA(value) actual_result = dna.transcribe(False) assert actual_result == expected_result
def test_reverse_complement_method_of_dna_class(value, expected_result): dna = MyDNA(value) actual_result = dna.reverse_complement() assert actual_result == expected_result
def test_incorrect_gc_content_method_of_dna_class_with_empty_str(): with pytest.raises(ValueError, match="at least one element"): MyDNA("").gc_content()
def test_correct_gc_content_method_of_dna_class(value, expected_result): dna = MyDNA(value) actual_result = dna.gc_content() assert actual_result == expected_result
def test_incorrect_construction_method_of_dna_class_with_not_dna_seq(value): with pytest.raises(TypeError, match="(contains A, T, C, G or N)"): MyDNA(value)
def test_incorrect_construction_method_of_dna_class_with_not_string(value): with pytest.raises(TypeError, match="should be a string"): MyDNA(value)
def test_hashible_of_dna_class_value(): test_value = "test_value" test_key = MyDNA("atgc") test_dict = {test_key: "test_value"} assert test_value == test_dict[test_key]
def test_not_equal_class_vs_str(): assert MyDNA("ATGC") != "ATGC"
def test_not_equal_of_dna_class(): assert MyDNA("atgc") != MyDNA("a")
def test_correct_construction_method_of_dna_class(value, expected_result): dna = MyDNA(value) actual_result = dna.dna assert actual_result == expected_result
def test_equal_of_dna_class(): assert MyDNA("atgc") == MyDNA("atgc")
def test_dna_into_rna_class(): dna = MyDNA("ATGC") rna = MyRNA(dna.transcribe()) assert rna == MyRNA("AUGC")