Answered step by step
Verified Expert Solution
Question
1 Approved Answer
from _ _ future _ _ import annotations from four _ in _ a _ row import * from a 0 import * # TODO
from future import annotations
from fourinarow import
from a import
# TODO add tests for each method and function as indicated in the assignment
# Note: we have scaffolded some code below for you to add your tests into.
# Make sure each test has a unique name and that each test starts
# with test
# The tests below are organized into classes to help keep related tests
# grouped together. In PyCharm you can choose to run all tests in a single
# class by using the run button beside the class name just like how you
# can choose to run a single test Alternatively, you can run all tests
# in the file by rightclicking the file name and choosing to run tests.
class TestHelpers:
These are provided tests related to Task which are meant to remind you
of the structure of a pytest for later tasks. For Task you are asked
to write doctests instead.
While not required, you are welcome to add other pytests here as you
develop your code.
def testwithingridingridself:
Test that is inside a by grid."""
assert withingrid
def testwithingridoutsidegridself:
Test that is outside a by grid."""
assert not withingrid
def testallwithingridallingridself:
Test when the four coordinates are all within a by grid."""
assert allwithingrid
def testreflectverticallyaboveself:
Test reflecting vertically for a coordinate above the middle."""
assert reflectvertically
def testreflectverticallymiddleself:
Test reflecting vertically for a coordinate on the middle row."""
assert reflectvertically
def testreflectpointsself:
Test reflecting a very short line"""
assert reflectpoints
class TestLine:
TODO Task : add tests for the Line methods and related functions
You must write two tests for each of:
isrow, iscolumn, and isdiagonal
Line.drop, Line.isfull, and Line.hasfiar
pass
class TestGrid:
TODO Task : add tests for the Grid methods and related functions
You must write two tests for each of:
Grid.drop, Grid.isfull
createrowsandcolumns
TODO Task : add tests for the Grid methods and related functions
You must write two tests for each of:
Grid.hasfiar
createmapping
pass
class TestFourInARow:
TODO TASK :
run checkcoverage.py to get the code coverage report.
Using the code coverage report, identify which branches of the code
are not currently being tested.
add tests below in order to achieve code coverage when you run
checkcoverage.py Your tests should follow a similar structure
to the testxwins test defined below.
def testxwinsself None:
Provided test demonstrating how you can test FourInARow.play using
a StringIO object to "script" the input.
See both the handout and the Task section of the supplemental slides
for a detailed explanation of this example.
fiar playgameGAMESCRIPTXWINS
assert fiar.result WIN
# TODO Add your tests for Task here. Make sure each test has a unique name
# and that each test starts with test
if namemain:
import pytest
pytest.maintestapy
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started