def test_spacesDoNotDegradePoint():
    testDurability = 5
    pencil = Pencil(testDurability, 0)

    pencil.write("oo oo")

    assert pencil.durability == 1
def test_upperCaseLettersDegradePointTwiceAsFast():
    testDurability = 5
    pencil = Pencil(testDurability, 0)

    pencil.write("Test")

    assert pencil.durability == 0
def test_durabilityLowersForEachCharacter():
    testDurability = 5
    pencil = Pencil(testDurability, 0)

    pencil.write("test")

    assert pencil.durability == 1
def test_sharpeningPencilReducesLength():
    testDurability = 5
    testLength = 3
    pencil = Pencil(testDurability, testLength)

    pencil.sharpen()

    assert pencil.length == testLength - 1
def test_pencilHasLength():
    testDurability = 5
    testLength = 3

    pencil = Pencil(testDurability, testLength)

    assert pencil.length == testLength
def test_paperCanAddPencil():
    pencil = Pencil(5, 0)
    paper = Paper()

    paper.addPencil(pencil)

    assert paper.pencil is not None
def test_WriteAddsStringToContent():
    testString = "string"
    paper = Paper()
    pencil = Pencil(25, 0)

    paper.write(testString, pencil)

    assert paper.content == testString
def test_dullPencilOnlyAddsWhitespace():
    pencil = Pencil(5, 0)
    paper = Paper()
    testString = "Bow wow"
    expectedString = "Bow w  "

    paper.write(testString, pencil)

    assert paper.content == expectedString
def test_eraseStringRemovesLastInstanceOfStringFromContent():
    pencil = Pencil(25, 0)
    paper = Paper()
    testString = "taco taco taco"
    expectedString = "taco taco     "
    paper.write(testString, pencil)

    paper.erase("taco")

    assert paper.content == expectedString
def test_WriteAppendsStringToContent():
    testOne = "test"
    testTwo = " two"
    paper = Paper()
    pencil = Pencil(25, 0)

    paper.write(testOne, pencil)
    paper.write(testTwo, pencil)

    assert paper.content == F"{testOne}{testTwo}"
def test_sharpeningPencilRestoresDurability():
    testDurability = 5
    testLength = 3
    pencil = Pencil(testDurability, testLength)
    pencil.write("boo")

    pencil.sharpen()

    assert pencil.durability == testDurability
def test_sharpeningPencilWithNoLengthDoesNothing():
    testDurability = 5
    testLength = 0
    testString = "boo"
    pencil = Pencil(testDurability, testLength)
    pencil.write(testString)

    pencil.sharpen()

    assert pencil.durability == testDurability - len(testString)
def test_canBeSetWithDurability():
    testDurability = 25
    pencil = Pencil(testDurability, 0)

    assert pencil.durability == 25
def test_pencilExists():
    pencil = Pencil(0, 0)

    assert pencil.durability == 0
Example #15
0
from pencilkatapython.paper import Paper
from pencilkatapython.pencil import Pencil
from os import system

paper = Paper()
pencil = Pencil(15, 5)

exit = "n"
selection = ""

while exit != "y":
    system('clear')
    print(F"Your Paper Shows: {paper.content}")
    print(
        F"Your Pencil Point is {pencil.durability} and Length of {pencil.length}"
    )
    selection = input(
        "Do you want to <write>, <sharpen>, or <erase>? Type in your answer: ")
    print()
    print()

    if selection == "write":
        writing = input("Type in what you want to write: ")
        paper.write(writing, pencil)
        print(F"Your Paper Shows: {paper.content}")
        print()
    elif selection == "sharpen":
        pencil.sharpen()
        print(
            F"Your Pencil Point is {pencil.durability} and Length of {pencil.length}"
        )