File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed
Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 55
66setuptools .setup (
77 name = "ip2location-io" ,
8- version = "1.0.3 " ,
8+ version = "1.0.4 " ,
99 author = "IP2Location" ,
1010 author_email = "support@ip2location.com" ,
1111 description = "This SDK provides users with the ability to perform IP geolocation lookup and domain WHOIS lookup through a web service." ,
Original file line number Diff line number Diff line change 11import pytest
2+ import os
23
3- @pytest .fixture (scope = 'module' )
4- def global_data ():
5- return {'apikey' : "YOUR_API_KEY" }
4+ def pytest_addoption (parser ):
5+ """
6+ Add a command-line option to pytest to pass the API key.
7+ """
8+ parser .addoption (
9+ "--apikey" ,
10+ action = "store" ,
11+ default = None ,
12+ help = "API Key for IP2Location.io Python tests"
13+ )
14+
15+ @pytest .fixture (scope = "session" )
16+ def global_data (request ):
17+ """
18+ Fixture to provide global test data, including the API key.
19+
20+ The API key can be passed as a command-line argument or through an
21+ environment variable. Command-line argument takes precedence.
22+ """
23+ # First, try to get the API key from the command-line argument
24+ api_key = request .config .getoption ("--apikey" )
25+
26+ # If no API key is provided via command line, fallback to environment variable
27+ if not api_key :
28+ api_key = os .getenv ("IP2LOCATION_API_KEY" )
29+
30+ # If neither command-line argument nor environment variable is set, raise an error
31+ if not api_key :
32+ pytest .fail ("API key is not set. Pass it via the --apikey argument or set the IP2LOCATION_API_KEY environment variable." )
33+
34+ # Return the global data containing the API key
35+ return {
36+ "apikey" : api_key ,
37+ # Add any other global data as needed
38+ }
You can’t perform that action at this time.
0 commit comments