-
Notifications
You must be signed in to change notification settings - Fork 512
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
What should I do if I want to make a library Brython-compatible? #1381
Comments
@glyph |
Creating that But more importantly, how is |
I spent the week thinking about it. I thought of creating dummies or mocks, to "emulate" Bryhton's behavior. So we could use the entire testing ecosystem. Like tox, pytest, mutation tests, coverage, linters. But I cannot imagine the depth and time that would be invested in this creation. Besides the fact that mocks never really behave as they would look inside the browser. In that case we would still need something like selenium to make e2e. |
There's also quite a bit of divergent behavior within the Brython runtime; for example, coroutines do not function according to spec, and there are big chunks of missing standard library functionality. Testing interactions with the DOM is a tiny fraction of what I'm worried about - I want to have test coverage that ensures things actually run within the browser context, not just that they're calling the right APIs… |
(So a lot of the value of having a very basic test runner would be a to expose the set of divergent-from-CPython behaviors which are actually relied upon by existing libraries, rather than the ones that it seems like would be helpful to implement for fresh new code) |
Maybe a basic start here would be something to run over a unittest test suite that would automatically emit the relevant index.html? |
+1 on question. Hoping to get brython working with plotly.js |
This is a subset of #491 that is focused specifically on libraries that might want to run on both Brython and CPython without much difference in functionality; things for implementing data structures, file formats, etc.
Writing Python code in the manner that I am accustomed to—particularly to take advantage of the "same language as the backend" feature that Brython offers—would require using tons of libraries that are currently broken on Brython. To get those fixed we'll need to add continuous integration to tons of projects.
As an open-source library author, if I want to support a different runtime such as PyPy, I usually just drop a new environment into my
tox.ini
, then run my tests as I did previously, with the same runner.However, the best practice for doing this on Brython is somewhat unclear - there have been a few interesting blog posts about testing an application using Selenium or whatever, but for libraries like automat glyph/automat#124 that don't have any UI features but might just be useful utilities within the browser… what's the first step?
I tried to proof-of-concept this with a custom unittest runner via https://github.com/glyph/brytly/blob/0d7c313830e3fc1ddf71986dec1473df048b6ae4/brytly/phantestic.py / https://github.com/glyph/brytly/blob/0d7c313830e3fc1ddf71986dec1473df048b6ae4/brytly/phantestic.js but this was always a pretty brittle hack and was pretty invasive - it required using this specific test fixture class.
Getting something like pytest to work within brython I would imagine would be a major challenge in its own right, but even if we're going to stick just to stdlib unittest for the sake of compatibility it seems like forcing users to use an incomplete reimplementation for their base class is going to be a non-starter for most projects.
The text was updated successfully, but these errors were encountered: