0

test_plates:

from plates import is_valid


def test_correct():
    assert (is_valid("ASD123")) == True
    assert (is_valid("ASD")) == True
    assert (is_valid("AS2")) == True
    assert (is_valid("AS")) == True
    assert (is_valid("ASasas")) == True

def test_incorrect_start():
    assert (is_valid("A'shelpa")) == False
    assert (is_valid("'2Ashelpa")) == False

def test_incorrect_number_placement():
    assert (is_valid("2Ahelpa")) == False
    assert (is_valid("A2helpa")) == False
    assert (is_valid("A2help2a")) == False

def test_incorrect_zero():
    assert (is_valid("Ahelpa02")) == False
    assert (is_valid("Ahelpa0")) == False


def test_incorrect_pattern():
    assert (is_valid("kel,l12")) == False
    assert (is_valid("kel l12")) == False
    assert (is_valid("kel.l12")) == False
    assert (is_valid("kel-l12")) == False
    assert (is_valid("kel;l12")) == False
    assert (is_valid("kel:l12")) == False
    assert (is_valid("02")) == False


def test_incorrect_length_small():
    assert (is_valid("A")) == False


def test_incorrect_length_big():
    assert (is_valid("Afgjrjnsvkngltnjsngjt")) == False

Pytest on my local system works properly for the cases

I am getting below errors:

:( test_plates catches plates.py without beginning alphabetical checks

:( test_plates catches plates.py without checks for number placement

:( test_plates catches plates.py without checks for zero placement

:( test_plates catches plates.py without checks for alphanumeric characters

1
  • One reason for most of those failures is that the strings you're using will first fail the length check. To fix this, make sure all your test strings are between 2 and 6 characters. In general, if you make sure all your test strings are constructed so that they only fail one specific type of test, the tests should pass.
    – Rufus L
    Commented Jun 22 at 18:26

1 Answer 1

1

I am posting the answer so that if somebody faces similar issue, they find it helpful.

I had missed to include an important information from the original vanity plates problem while doing this problem. It was 'Assume that any letters in the user’s input will be uppercase' . After modifying my test data accordingly, it worked

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .