def get_patched_get_url(patched_urlopen, testcase=None):
    """Get the URL of the GET request made to the patched urlopen() function.

    Expects that the patched function should have been called a single time with the url as the only
    positional argument and no keyword arguments.

    :param patched_urlopen: value returned when entering the context manager created by patch_urlopen.
    :type patched_urlopen: unittest.mock.Mock
    :param testcase: Test case currently being run, which is used to make asserts
    :type testcase: unittest.TestCase
    """
    args, kwargs = patched_urlopen.call_args

    if testcase is not None:
        testcase.assertEqual(patched_urlopen.call_count, 1)
        testcase.assertEqual(len(args), 1)
        testcase.assertEqual(len(kwargs), 0)

    return args[0]