I started learning playwright and from documentation (https://playwright.dev/python/docs/intro) tried to to run the following sample code:
import re
from playwright.sync_api import Page, expect
def test_pp(page: Page):
page.goto("https://playwright.dev/")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
# create a locator
get_started = page.locator("text=Get Started")
# Expect an attribute "to be strictly equal" to the value.
expect(get_started).to_have_attribute("href", "/docs/intro")
# Click the get started link.
get_started.click()
# Expects the URL to contain intro.
expect(page).to_have_url(re.compile(".*intro"))
While running using command pytest, throwing following error:
file D:\play_wright\test\test_sample.py, line 5
def test_pp(page: Page):
E fixture 'page' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
D:\play_wright\test\test_sample.py:5
pytest-playwright module (0.3.0) is installed. confirmed with pip list command
Restarted Widows Machine
playwright version - 1.27.1
pytest - 6.2.1 (tried with 7.* as well)
Still getting the issue. please help.
I had the same issue as well. I ran this command, then restarted my command line and it started working.
playwright install-deps
I hope this helps.
Try the following:
py.test test_.py
The issue that we are getting is : we have run manage.py makemigrations and manage.py migrate successfully, after which we start getting the below error:
File "/usr/local/goibibo/python/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 110, in execute
return self.cursor.execute(query, args)
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler
raise errorvalue
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/usr/local/goibibo/python/lib/python3.5/site-packages/MySQLdb/connections.py", line 292, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (2027, 'Malformed packet')
This issue does not come every time we run makemigrations.
It comes randomly, but once it comes it just sticks and we have no clue on why this is happening.
Can somebody assist us in fixing this and explain why this might be happening.
Packages Used in App:
adium-theme-ubuntu==0.3.4
appdirs==1.4.3
asn1crypto==0.22.0
backports-abc==0.5
blinker==1.4
boto3==1.4.4
botocore==1.5.35
certifi==2017.4.17
cffi==1.10.0
chardet==2.3.0
click==6.7
ConcurrentLogHandler==0.9.1
configobj==5.0.6
decorator==4.0.11
Django==1.10.4
djangorestframework==3.5.3
docutils==0.13.1
Flask==0.11.1
futures==3.1.1
gevent==1.2a1
greenlet==0.4.10
gyp==0.1
idna==2.5
itsdangerous==0.24
Jinja2==2.8
jmespath==0.9.2
jsonpatch==1.10
jsonpath==0.75
jsonpath-rw==1.4.0
jsonpointer==1.10
MarkupSafe==1.0
newrelic==2.82.0.62
oauthlib==1.0.3
packaging==16.8
Pillow==3.1.2
ply==3.10
prettytable==0.7.2
pyasn1==0.1.9
pycparser==2.17
pycurl==7.43.0
PyJWT==1.3.0
PyMySQL==0.7.9
PyOpenGL==3.0.2
pyparsing==2.2.0
Pyrex==0.9.8.5
pyserial==3.0.1
PySocks==1.6.5
python-dateutil==2.6.0
PyYAML==3.11
requests==2.14.2
s3transfer==0.1.10
singledispatch==3.4.0.3
six==1.10.0
SQLAlchemy==1.1.4
ssh-import-id==5.5
tornado==4.4.2
unity-lens-photos==1.0
urllib3==1.19.1
virtualenv==15.1.0
Werkzeug==0.12.1
Resolved in mysql 5.6.17 by SET read_rnd_buffer_size=256000 for the session. Did not have to change my.ini (cfg).
Same issue haunted my team for a while, and there's very little useful information about it on the web. We spent a lot of time troubleshooting the issue - and FINALLY found solution that solved it (at least - for our team)!
We found that Django sets "charset" option to "utf8" for database connections by default. During troubleshooting we used two separate database connection objects: one created for us by Django, and another - created manually using direct _mysql.connect() command. When we executed same exact query using both connection objects - the one created by Django resulted in "django.db.utils.OperationalError: (2027, 'Malformed packet')" (which is exactly what we were getting in our API), but the second connection (manual) - worked without any issues. Further comparison of the two connection objects (we actually had to use Python debugger "pdb" and set breakpoint within django.db.backends.mysql.base.py for that) - revealed that Django creates connection by passing "charset":"utf8", while manual _mysql connection - uses "latin1". As soon as we added "charset":"latin1" to DATABASES["default"]["OPTIONS"] within our settings.py - this error disappeared.
To summarize, solution (for us) was to explicitly set "charset":"latin1" within "OPTIONS" config section of DATABASES configuration - for every database alias. I can not say for sure that this will work for everyone who experiences this error - but it certainly works for us.
I'm trying to write a CMS content migration script that will create our pages for django-cms. However even with the default install of Django-cms, Django-treebeard keeps raising exceptions and it's not clear to me why.
For example, when this line is executed:
api.create_page(title="Hello world",
language='en',
parent=None)
My script always fails here (line 307-8) in mp_tree.py (v 4.1.0) from treebeard:
if newobj.pk:
raise NodeAlreadySaved("Attempted to add a tree node that is "\
"already in the database")
Does anyone have a very simple example on how to use the cms.api.create_page() method?
http://docs.django-cms.org/en/release-3.4.x/reference/api_references.html?highlight=create_page#cms.api.create_page
Pip freeze shows these versions:
aldryn-apphooks-config==0.2.7
aldryn-boilerplates==0.7.4
aldryn-common==1.0.4
aldryn-faq==1.2.2
aldryn-forms==2.1.3
aldryn-reversion==1.0.9
aldryn-search==0.3.0
aldryn-translation-tools==0.2.1
appdirs==1.4.3
boto==2.46.1
boto3==1.4.4
botocore==1.5.26
cmsplugin-filer==1.1.3
contextlib2==0.5.4
cssselect==1.0.0
cssutils==1.0.1
dj-database-url==0.4.1
Django==1.8.17
django-absolute==0.3
django-admin-sortable==2.0.21
django-admin-sortable2==0.6.6
django-appconf==1.0.2
django-appdata==0.1.6
django-cas-ng==3.5.6
django-classy-tags==0.8.0
django-cms==3.4.1
django-cors-headers==2.0.2
django-debug-toolbar==1.7
django-emailit==0.2.2
django-environ==0.4.1
django-extensions==1.7.7
django-filer==1.2.5
django-formtools==1.0
django-haystack==2.5.1
django-mptt==0.8.6
django-parler==1.6.5
django-polymorphic==0.8.1
django-reversion==1.10.2
django-sekizai==0.10.0
Django-Select2==4.3.2
django-simple-captcha==0.5.3
django-sizefield==0.9.1
django-sortedm2m==1.3.2
django-spurl==0.6.4
django-standard-form==1.1.1
-e git+https://github.com/jschneier/django-storages.git#043b91b10ebfebdf7e752d743ae630f0daa2c4f4#egg=django_storages
django-storages-redux==1.3.2
django-tablib==3.1.2
django-taggit==0.21.3
django-treebeard==4.1.0
djangocms-admin-style==1.2.6.2
djangocms-attributes-field==0.1.2
djangocms-column==1.7.0
djangocms-googlemap==1.0.1
djangocms-installer==0.9.3
djangocms-link==2.0.3
djangocms-rest-api==0.2.0
djangocms-snippet==1.9.2
djangocms-style==2.0.1
djangocms-text-ckeditor==3.3.1
djangocms-video==2.0.3
djangorestframework==3.4.7
docutils==0.13.1
easy-thumbnails==2.3
google-auth==0.8.0
google-auth-httplib2==0.0.2
google-cloud-core==0.23.1
google-cloud-storage==0.23.1
googleapis-common-protos==1.5.2
html5lib==0.9999999
httplib2==0.10.3
jmespath==0.9.0
lxml==3.7.0
mysqlclient==1.3.10
packaging==16.8
Pillow==3.4.2
premailer==3.0.1
protobuf==3.2.0
psycopg2==2.6.2
pyasn1==0.2.3
pyasn1-modules==0.0.8
pyparsing==2.2.0
python-cas==1.2.0
python-dateutil==2.6.0
python-slugify==1.2.0
pytz==2016.10
raven==6.0.0
requests==2.12.3
rsa==3.4.2
s3transfer==0.1.10
six==1.10.0
sqlparse==0.2.3
tablib==0.11.3
tzlocal==1.3
Unidecode==0.4.19
URLObject==2.4.2
YURL==0.13
So thanks to #dentemm and #paulo I was able to get this running in a Python shell as follows:
>>> from cms import constants
>>> from cms.constants import TEMPLATE_INHERITANCE_MAGIC
>>> from cms import api
>>> api.create_page(title="Hello World4",language='en',template=TEMPLATE_INHERITANCE_MAGIC,parent=None)
<cms.models.pagemodel.Page object at 0x102b674e0>
It was failing because I was not including the 'template' argument and the necessary imports.
I am unsure if it's the cause for your problems, but there is an error in your api.create_page() code above: parent=None shouldn't have spaces.
I'm trying to build a project which uses Buildout and I'm behind a proxy but there's a problem with hostname verification. I couldn't find the root of the problem as passing multiple -v options to buildout command seems to not increase verbosity in this case. I couldn't find any information on buildout's interaction with proxies neither at http://www.buildout.org/en/latest/docs/index.html (which is version 1.2.1!?) nor at https://pypi.python.org/pypi/zc.buildout/2.2.1
pdobrogost#host:~/projects/projectx/projectx_buildout$ python bootstrap.py -c buildout-devel.cfg
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Getting distribution for 'setuptools'.
/opt/python/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'src_root'
warnings.warn(msg)
Got setuptools 5.7.
Getting distribution for 'zc.buildout==1.4.3'.
Got zc.buildout 1.4.3.
pdobrogost#host:~/projects/projectx/projectx_buildout$ ./bin/buildout -vNc buildout-devel.cfg custom:cvsuser=pdobrogost
Installing 'mr.developer'.
We have no distributions for mr.developer that satisfies 'mr.developer'.
Download error on http://pypi.python.org/simple/mr.developer/: hostname 'proxy.site.local' doesn't match either of '*.c.ssl.fastly.net', 'c.ssl.fastly.net', '*.target.com', '*.vhx.tv', '*.snappytv.com', '*.atlassian.net', 'secure.lessthan3.com', '*.atlassian.com', 'a.sellpoint.net', 'cdn.upthere.com', '*.tissuu.com', '*.issuu.com', '*.kekofan.com', '*.python.org', '*.theverge.com', '*.sbnation.com', '*.polygon.com', '*.twobrightlights.com', '*.2brightlights.info', '*.vox.com', 'staging-cdn.upthere.com', '*.zeebox.com', '*.beamly.com', '*.aticpan.org', 'stream.svc.7digital.net', 'stream-test.svc.7digital.net', '*.articulate.com', 's.t.st', 'vid.thestreet.com', '*.planet-labs.com', '*.url2png.com', 'turn.com', 'www.turn.com', 'rivergathering.org', 'social.icfglobal2014-europe.org', '*.innogamescdn.com', '*.pathable.com', '*.staging.pathable.com', '*.kickstarter.com', 'sparkingchange.org', 'www.swedavia.se', 'www.swedavia.com', 'js-agent.newrelic.com', '*.fastly-streams.com', 'cdn.brandisty.com', 'fastly.hightailcdn.com', '*.fl.yelpcdn.com', '*.feedmagnet.com', 'api.contentbody.com', '*.acquia.com', '*.swarmapp.com', '*.pypa.io', 'pypa.io', 'static.qbranch.se', '*.krxd.net', '*.room.co', '*.metrological.com', 'room.co', 'cdn.evbuc.com', 'cdn.adagility.com', '*.bandpage.com', '*.ibmserviceengage.com', '*.quirky.com', '*.veez.co', '*.x.io', '*.otoycdn.net', '*.scribd.com', 'www.dwin1.com', 'api.imgur-ysports.com', 'i.imgur-ysports.com', '*.fxcm.co.jp', 'listora.com', '*.listora.com', 'blendle.nl', '*.blendle.nl', '*.modeanalytics.com', 'modeanalytics.com', 'krux.com', '*.krux.com', '*.udemy.com', '*.1stdibs.com', 'api.keep.com', 'www.piriform.com', '*.ustream.tv', 'www.zimbio.com', 'm.zimbio.com', 'www.stylebistro.com', 'm.stylebistro.com', 'm.lonny.com', 'www.lonny.com', 'assets.trabiancdn.com', '*.socialchorus.com', '*.heritagestatic.com', '*.theoutbound.com', 'img.rakuten.com', 'images.rakuten.com', 'img1.r10.io', 'ast1.r10.io', 'scribd.com' -- Some packages may not be found!
Couldn't find index page for 'mr.developer' (maybe misspelled?)
Download error on http://pypi.python.org/simple/: hostname 'proxy.site.local' doesn't match either of '*.c.ssl.fastly.net', 'c.ssl.fastly.net', '*.target.com', '*.vhx.tv', '*.snappytv.com', '*.atlassian.net', 'secure.lessthan3.com', '*.atlassian.com', 'a.sellpoint.net', 'cdn.upthere.com', '*.tissuu.com', '*.issuu.com', '*.kekofan.com', '*.python.org', '*.theverge.com', '*.sbnation.com', '*.polygon.com', '*.twobrightlights.com', '*.2brightlights.info', '*.vox.com', 'staging-cdn.upthere.com', '*.zeebox.com', '*.beamly.com', '*.aticpan.org', 'stream.svc.7digital.net', 'stream-test.svc.7digital.net', '*.articulate.com', 's.t.st', 'vid.thestreet.com', '*.planet-labs.com', '*.url2png.com', 'turn.com', 'www.turn.com', 'rivergathering.org', 'social.icfglobal2014-europe.org', '*.innogamescdn.com', '*.pathable.com', '*.staging.pathable.com', '*.kickstarter.com', 'sparkingchange.org', 'www.swedavia.se', 'www.swedavia.com', 'js-agent.newrelic.com', '*.fastly-streams.com', 'cdn.brandisty.com', 'fastly.hightailcdn.com', '*.fl.yelpcdn.com', '*.feedmagnet.com', 'api.contentbody.com', '*.acquia.com', '*.swarmapp.com', '*.pypa.io', 'pypa.io', 'static.qbranch.se', '*.krxd.net', '*.room.co', '*.metrological.com', 'room.co', 'cdn.evbuc.com', 'cdn.adagility.com', '*.bandpage.com', '*.ibmserviceengage.com', '*.quirky.com', '*.veez.co', '*.x.io', '*.otoycdn.net', '*.scribd.com', 'www.dwin1.com', 'api.imgur-ysports.com', 'i.imgur-ysports.com', '*.fxcm.co.jp', 'listora.com', '*.listora.com', 'blendle.nl', '*.blendle.nl', '*.modeanalytics.com', 'modeanalytics.com', 'krux.com', '*.krux.com', '*.udemy.com', '*.1stdibs.com', 'api.keep.com', 'www.piriform.com', '*.ustream.tv', 'www.zimbio.com', 'm.zimbio.com', 'www.stylebistro.com', 'm.stylebistro.com', 'm.lonny.com', 'www.lonny.com', 'assets.trabiancdn.com', '*.socialchorus.com', '*.heritagestatic.com', '*.theoutbound.com', 'img.rakuten.com', 'images.rakuten.com', 'img1.r10.io', 'ast1.r10.io', 'scribd.com' -- Some packages may not be found!
Getting distribution for 'mr.developer'.
While:
Installing.
Loading extensions.
Getting distribution for 'mr.developer'.
Error: Couldn't find a distribution for 'mr.developer'.
I have proxies set as following:
pdobrogost#host:~/projects/projectx/projectx_buildout$ env | grep proxy
http_proxy=http://proxy.site.local:8080
https_proxy=http://proxy.site.local:8080
no_proxy=localhost,127.0.0.1,.site.local,192.168.*
Also, buildout-devel.cfg extends buildout.cfg where the following versions are specified:
[versions]
zc.buildout = 1.4.3
zc.recipe.egg = 1.2.2
For comparision, with wget I get this:
pdobrogost#host:~/projects/projectx/projectx_buildout$ wget http://pypi.python.org/simple/mr.developer
--2014-09-05 10:56:20-- http://pypi.python.org/simple/mr.developer
Resolving proxy.site.local... 192.168.10.132
Connecting to proxy.site.local|192.168.10.132|:8080... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://pypi.python.org/simple/mr.developer [following]
--2014-09-05 10:56:20-- https://pypi.python.org/simple/mr.developer
Connecting to proxy.site.local|192.168.10.132|:8080... connected.
ERROR: certificate common name “*.c.ssl.fastly.net” doesn’t match requested host name “pypi.python.org”.
To connect to pypi.python.org insecurely, use ‘--no-check-certificate’.
Not sure if this is directly related, but your post came up when trying to find an answer to my problem. It looks like there may be an issue with some versions of Python (3.4 in my case) where it could not install dependencies behind a proxy. It looks like it's related to this: (https://github.com/shazow/urllib3/pull/385) It looks like the buildout script may be running into the same issue?
For a work-around in my case where I'm only using pip, I was able to install each dependency manually. So keep trying to install the main package with pip, then when it fails saying it can't find a package, pip install that package and try again.
You can try using http, by selecting different mirror that supports http as outlined in this guide -- http://jacobian.org/writing/when-pypi-goes-down/
For buildout, you will need to add the following as global declaration
[global]
index-url = http://pypi.python.org/simple
The main problem, however that pypi.python.org is now set up to serve https only and will still redirect you to https site even if your using http, so the only real solution is to create a mirror somewhere outside and serve pypi content via http.