Python port scanner project wrong test

Hello, I just finished the Python Port Scanner project and it passed the web validator.
The fun fact is that it was failing one test in replit. I looked at the test code and I think it is not correctly implemented.

def test_port_scanner_verbose_ip_hostname_returned_multiple_ports(self):
        str = port_scanner.get_open_ports("137.74.187.104", [440, 450], True)
        actual = str
        expected = "Open ports for hackthissite.org (137.74.187.104)\nPORT     SERVICE\n443      https"
        self.assertEqual(actual, expected, "Expected 'Open ports for hackthissite.org (137.74.187.104)\nPORT     SERVICE\n443      https'")

As you can see the first argument for port_scanner.get_open_ports is the IP address but in the expected answer it require the Hostname + IP address. Either change the first parameter to the hostname or the answer to expect only IP, otherwise it will not work if we complete the project according to the given info. Also the function title is not what the result expect: Test port_scanner verbose ip HOSTNAME returned MULTIPLE PORTS. It doesn’t have hostname and don’t expect multiple ports returned, just one opened.

The web submission form doesn’t run any python tests. Honor system.

There’s no bug. You should be able to get the hostname or the IP from the other, assuming the hostname exists. The spec asks for hostname and IP in verbose mode, if the hostname is available (hence the two tests, with and without hostname, at least on the old tests). I suppose you have a point about the singular/plural ports in the name, but my guess is these tests were copied/pasted from one of the other tests with multiple ports open.

I see, I updated my code so now all tests pass.
Thank you for the reply.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.