Comments (11)
@bollwyvl Thanks for the update, and also for maintaining the conda forge package.
from pytest-console-scripts.
@kvas-it thanks for this package!
@emthompson-usgs we just updated the conda-forge package to 1.1.0 and run the tests during the build with coverage thresholds, so it should keep working when new versions drop. It should be generally available within the hour (there's some CDN stuff that has to happen, above my paygrade). Please feel free to reach out on the feedstock in the future with any seemingly conda-related issues with this package!
from pytest-console-scripts.
Hi, Eric! In principle pytest-console-scripts should work on Windows, but I have never tested it there because I don't have a Windows machine handy. I had an impression that other people have successfully used it on Windows, but it definitely could be the case that some scenarios don't work because of platform differences. Perhaps you can post your test and error log here and then we can try to think together what's going wrong.
Cheers,
Vasily
from pytest-console-scripts.
Vasily,
Thanks for the offer to look at the tests and error logs. We are currently using Azure pipelines for testing and the logs can be found here. I'd be happy to make any adjustments that you think might be helpful and rerun (e.g., make the pytest output more verbose, or add specific print statements). I've experimented with that myself but couldn't find anything useful.
Here are my initial thoughts/observations:
- The specific error message appears to be an encoding issue. But the thing that is unique about the tests that are failing is that they are exclusively the tests where I pass in the stdin argument, and so am now thinking that the UnicodeDecodeError is being caused by something related to stdin:
tests\gmprocess\bin\eqprocess_test.py # Running console script: eqprocess projects -c
# Script return code: 1
# Script stdout:
# Script stderr:
Traceback (most recent call last):
File "C:\Miniconda\envs\gmprocess\lib\site-packages\py\_path\common.py", line 177, in read
return f.read()
File "C:\Miniconda\envs\gmprocess\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2: character maps to <undefined>
- The source code for the this test is here.
- The source code for the program being tested is here.
- I thought that it might be an issue with the newline character on windows being
\r
rather than\n
but changing that did not resolve the error. - I don't understand why the traceback doesn't indicate the line of code in this repository that is resulting in the error.
Any ideas/guidance would be greatly appreciated!
from pytest-console-scripts.
Thanks for all the info, Eric. Looks quite puzzling indeed. So it seems that the exception happens not in your code, because you don't use py.path
. However, pytest-console-scripts
also doesn't read from py.path
objects as far as I can see.
I will think more about what's happening, but for now I have this idea: it seems that we're not seeing the full traceback and we know that pytest-console-scripts is messing with the traceback here. Perhaps we can change tb.tb_next
to just tb
in this line, or even just rethrow the exception -- maybe this way we'll see better what's going on. Do you think you would be able to patch pytest-console-scripts
like this in your test run?
Cheers,
Vasily
P.S. From the error log I also see that we're attempting to decode something from cp1252 encoding, which probably only happens on Windows. This might be a hint as to why this only happens on Windows. Anyway, this is definitely not intentional and I'm not sure how we could act on this hint since we don't understand where it's happening now. So let's try the idea above first.
from pytest-console-scripts.
I don't know how to patch on Windows, so I think the easiest thing to do will be for me to fork the repo, make the change, and then install from the fork. I'll try that and report back.
from pytest-console-scripts.
Hi Vasily,
So, I got some unexpected results... here's the branch where I made the change you suggested, and I modified the azure build script to install from this branch. The logs are here. And oddly, rather than giving us a more thorough traceback message, the tests all pass now! I'm not going to pretend I understand why this change would solve the error, but it does appear that the tests are succeeding now.
Please let me know what you think this means.
Eric
from pytest-console-scripts.
Hi Eric!
This is kind of hilarious. A logical explanation would be that taking .tb_next
of tb
somehow causes the crash. It might very well be the case, although I'm not quite sure why. I don't have a ton of time to debug this but I think I have an idea. We could do the following:
- You add
.tb_next
back in your branch and check that the tests fail the same way they did originally. This way we exclude side effects of a slightly different setup. - If the tests start failing again with
.tb_next
, I would probably just remove it (we can merge your current branch as it is now or replace traceback printing withtraceback.print_exc()
to make it a bit simpler). I don't think this removing of the current frame helps much (it actually tends to make complicated failures harder to debug) and if it fixes your failure -- well, good riddance.
What do you think?
Cheers,
Vasily
from pytest-console-scripts.
Vasily,
Thanks for the guidance. You were correct to suspect something else was going on due to the different install approach. When I add back in the .tb_next
it still passes. So I reverted to the original build, and it failed. We use conda for dependency management, so the main difference is that we were getting pytest-console-scripts
from conda, and it looks like it is not being actively maintained, and so I was getting a very old version. So I will switch to installing with pip for now, and maybe eventually I can contact the conda feedstock maintainers to try to get their build issues resolved.
Eric
from pytest-console-scripts.
Hi Eric,
Happy to hear that you've found a solution. Also thank you for talking to the Conda folks about upgrading pytest-console-scripts
there.
It seems that there's nothing to do then, at least at this point. Shall we close this issue or is there anything else to do?
Cheers,
Vasily
from pytest-console-scripts.
Yes, thank you for taking the time to help me out. I'm closing the issue.
from pytest-console-scripts.
Related Issues (20)
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 24: invalid continuation byte HOT 8
- Running scripts that have not been installed HOT 10
- Encoding issues under Windows HOT 12
- extremely slow execution of script tests HOT 3
- Can I mock a function in the called script? HOT 5
- Add option to suppress printing RunResult on init HOT 8
- Mocking script methods when testing with pytest-console-scripts HOT 3
- Strange behaviour with Pytest when running script is imported as module in another test file. HOT 4
- print_result='on_fail' HOT 9
- “python_requires” should be set with “>=3.6”, as pytest-console-scripts 1.2.2 is not compatible with all Python versions. HOT 1
- PyPI Wheels? HOT 3
- 1.3.1: missing install-time dependencies HOT 5
- Test fails when called alone, succeeds with whole test module HOT 8
- Testing scripts which trigger user input HOT 4
- script_runner fixture type-hint. HOT 2
- Parity with subprocess.run HOT 3
- thank you for writing pytest-console-scripts
- Decode error when using inprocess tests on windows 10 HOT 1
- `pytest-console-scripts` causes `pytest-xdist` tests to fail HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-console-scripts.