Skip to content
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

Setting a CookieJar #542

Closed
jruizaranguren opened this issue Feb 17, 2017 · 1 comment
Closed

Setting a CookieJar #542

jruizaranguren opened this issue Feb 17, 2017 · 1 comment

Comments

@jruizaranguren
Copy link

I have added the following code to a locustfile.py:

from requests import CookieJar
# constant definitions skipped
COOKIE = CookieJar()
COOKIE.set(COOKIE_KEY, COOKIE_VAL, domain=COOKIE_DOMAIN, path=COOKIE_PAHT)

From the documentation, I expected that I could add this cookie in the request:

    @task(1)
    def isalive(self):
        """ Simply issue an isalive get request """
        self.client.get("/isalive", cookies=COOKIE)

But when I run locust I am getting an ImportError: cannot import CookieJar. This is my environment:

  • locust 0.8a2
  • Python 3.5.2 :: Anaconda 4.2.0 (64-bit)
@cgoldberg
Copy link
Member

ImportError: cannot import CookieJar

your import is incorrect.

instead, you can use:
from cookielib import CookieJar

note: you can also pass cookies as simple dicts, or let requests handle them automagically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants