#Python assertion error. my tests do not pass.
1 messages · Page 1 of 1 (latest)
It's best to send everything you can here and ask for help here. Usually people are reluctant to help in DM, specially when not all the info is given. https://dontasktoask.com/
You can see here the tests that failed and why but it's hard for us to say exactly the issue without more info.
One of your failures is from here:
def test_request_driver() -> None:
y = Rider('rider', 10, Location(1, 1), Location(10, 10))
x = Dispatcher()
output = x.request_driver(y)
assert output is None
z = Driver('driver', Location(0, 0), 10)
assert x.request_rider(z) == y
Why would you expect the output of x.request_driver(y) to be None
The logic of this whole method doesn't make mutch sense to me
Wouldn't you want something like:
def test_request_driver() -> None:
y = Rider('rider', 10, Location(1, 1), Location(10, 10))
x = Dispatcher()
z = x.request_driver(y)
assert output is not None
assert x.request_rider(z) == y
In the assertion failure x.request_driver(y) shows its returning a driver. so why would you request a driver and expect it to be None ?
i tried that but still the assertion error is there 🤔
ahh i see your point
Think about what the thing is actually trying to do
assert report == {'rider_wait_time': 2.0, 'driver_total_distance': 6.0, 'driver_ride_distance': 6.0}
this is the line it has a problem with
Do you maybe need to create a Driver and submit it to x
then what were u referring to?
wait so u think theres something wrong with the tests?
def test_request_driver() -> None:
the_dispatcher = Dispatcher()
the_driver = Driver('driver', Location(0, 0), 10)
the_rider = Rider('rider', 10, Location(1, 1), Location(10, 10))
# You need to tell the dispatcher that the driver exists
# before it can asssign a driver to the rider
z = the_dispatcher.request_driver(the_rider)
assert z is not None
assert the_rider == the_dispatcher.request_rider(the_driver)
The Dispatcher can't just divine that the driver exists when you create it
Well, at least this one seems wrong
I highly recommend you use better variable names than x y and z unless those are used in math formulas.
right
It looks like in at least that test test_request_driver you are attempting to test that the dispatcher will return the correct driver given a rider.
- make a dispatcher
- make a driver
- tell the dispatcher that the driver is ready for work
- make a rider
- ask the dispatcher to dispatch some driver
- ensure that the driver that the dispatcher is the exact same driver that you said was ready for work
yeah
ok so i guess the problem was with the way i was making the test cases
and not the code
at least in this case.