File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed
Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,35 @@ def pytest_addoption(parser):
77 """Add command line options for pytest."""
88 parser .addoption (
99 "--port" ,
10- action = "store" ,
11- default = 12346 ,
10+ action = "append" ,
1211 type = int ,
13- help = "Port number for TCP connection (default: 12346 )" ,
12+ help = "Port number for Balatro instance (use multiple times for parallel execution )" ,
1413 )
1514
1615
16+ def pytest_configure (config ):
17+ """Configure ports and distribution."""
18+ ports = config .getoption ("--port" ) or [12346 ]
19+
20+ # Remove duplicates while preserving order
21+ unique_ports = []
22+ for port in ports :
23+ if port not in unique_ports :
24+ unique_ports .append (port )
25+
26+ config ._balatro_ports = unique_ports
27+
28+ if len (unique_ports ) > 1 :
29+ config .option .dist = "loadscope"
30+
31+
1732@pytest .fixture (scope = "session" )
18- def port (request ):
19- """Get the port number from command line option."""
20- return request .config .getoption ("--port" )
33+ def port (request , worker_id ):
34+ """Get assigned port for this worker."""
35+ ports = getattr (request .config , "_balatro_ports" , [12346 ])
36+
37+ if worker_id == "master" :
38+ return ports [0 ]
39+
40+ worker_num = int (worker_id .replace ("gw" , "" ))
41+ return ports [worker_num % len (ports )]
You can’t perform that action at this time.
0 commit comments