-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PicklingError using live_server fixture on Windows #54
Comments
As per https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled the only top level function can be pickled. Re #54.
Thank you for the report. Sadly I have no possibility to reproduce or test your issue, but looks like it can be easily fixed. Please, test against |
Hi @vitalk - thanks for the quick response. I've tried that branch now and it fixes the previous error. However, a new error is given now:
|
I‘m sorry, but I‘m not sure I can be of much help (I don‘t run windows), but if you come up with a solution (or someone else), I‘ll happily review and merge. |
No worries, thanks for taking a look. |
I don't know if another report of the issue will help in anyway, but here it is:
|
@Nagasaki45 @vitalk
|
I'm running into the same thing. Makes me very :( I guess I'll just roll my own. |
This seems to work for me fine: import subprocess
import pytest
import requests
@pytest.fixture(scope="module", autouse=True)
def server():
server = subprocess.Popen(['python', '-m', 'app'])
time.sleep(1)
yield server
server.terminate()
def test_request():
response = requests.get('http://localhost:5000')
assert response.status_code == 200 |
I'm running into the same issue with Windows 10 and Python 3.6.7. |
Having this issue too in Windows 10 and Python 3.6 |
Any workaround for this? |
Improving on @Jitsusama workaround, using import pytest
import socket
import subprocess
@pytest.fixture(scope="session")
def flask_port():
## Ask OS for a free port.
#
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("", 0))
addr = s.getsockname()
port = addr[1]
return port
@pytest.fixture(scope="session", autouse=True)
def live_server(flask_port):
env = os.environ.copy()
env["FLASK_APP"] = "your_package.app_module"
server = subprocess.Popen(['flask', 'run', '--port', str(flask_port)], env=env)
try:
yield server
finally:
server.terminate() And then write your TestCases in test-files (e.g. import pytest
import requests
def test_request(flask_port):
response = requests.get(f"http://localhost:{flask_port}"')
assert response.status_code == 200 |
Hey, I'm new here. I get the same error on Windows 10, Python 3.12 trying to set up the live-server for use with selenium. |
Not sure if Windows is supposed to be supported, but for me it fails on Windows 10 Python 2.7.12 with the following error when live_server fixture used:
The text was updated successfully, but these errors were encountered: