示例#1
0
def test_get_all(countries_map):
    """
    Test that a list of all countries can be retrieved.
    """
    countries = rapi.get_all()
    assert sorted(countries) == sorted(countries_map.values())
def test_get_all_with_filter(countries_map):
    """
    Test that a list of all countries can be retrieved and the response is filtered.
    """
    countries = rapi.get_all(filters=["name", "capital"])
    assert sorted(countries) == sorted(countries_map.values())
示例#3
0
from restcountries import RestCountryApiV2 as rc
countries_list = rc.get_all()

for c in countries_list:
    print(c.name, "-", c.capital, "-", end="")

    for curr in c.currencies:
        code, name, symbol = curr.items()
        print(code, name, symbol, end="")
    print()
示例#4
0
from restcountries import RestCountryApiV2 as rc

# for c in rc.get_countries_by_name("india"):
#     print(type(c))
#     print(dir(c))

for c in rc.get_all():
    print(c.name, ' - ', c.capital)