コード例 #1
0
def test_hashible_of_dna_class():
    try:
        print(set(MyDNA("atgc")))
        print({MyDNA("atgc"): "smt"})

    except TypeError:
        raise pytest.fail("in hash dna test")
コード例 #2
0
def test_iterable_of_dna_class(value, expected_result):
    dna = MyDNA(value)
    actual_result = [nucl for nucl in dna]

    assert expected_result == actual_result
コード例 #3
0
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)
コード例 #4
0
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
コード例 #5
0
def test_reverse_complement_method_of_dna_class(value, expected_result):
    dna = MyDNA(value)
    actual_result = dna.reverse_complement()
    assert actual_result == expected_result
コード例 #6
0
def test_incorrect_gc_content_method_of_dna_class_with_empty_str():
    with pytest.raises(ValueError, match="at least one element"):
        MyDNA("").gc_content()
コード例 #7
0
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
コード例 #8
0
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)
コード例 #9
0
def test_incorrect_construction_method_of_dna_class_with_not_string(value):
    with pytest.raises(TypeError, match="should be a string"):
        MyDNA(value)
コード例 #10
0
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]
コード例 #11
0
def test_not_equal_class_vs_str():
    assert MyDNA("ATGC") != "ATGC"
コード例 #12
0
def test_not_equal_of_dna_class():
    assert MyDNA("atgc") != MyDNA("a")
コード例 #13
0
def test_correct_construction_method_of_dna_class(value, expected_result):
    dna = MyDNA(value)
    actual_result = dna.dna
    assert actual_result == expected_result
コード例 #14
0
def test_equal_of_dna_class():
    assert MyDNA("atgc") == MyDNA("atgc")
コード例 #15
0
def test_dna_into_rna_class():
    dna = MyDNA("ATGC")
    rna = MyRNA(dna.transcribe())

    assert rna == MyRNA("AUGC")