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

The tests fail for the Worker Class: io.UnsupportedOperation: fileno #7

Closed
devinbfergy opened this issue Aug 21, 2019 · 4 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@devinbfergy
Copy link
Contributor

The tests included with this repository fail execution via an io.UnsupportedOperation: fileno

Expected Behavior

The expected behavior is that one should be able to provide the input and output streams as StringIO objects and run the Code. The tests rely on the ability to load configuration files/ input files via stdin at runtime.

Current Behavior

The current behavior is the tests fail with the following same result:
image

Possible Solution

The solution could be to change the assumption that r, w, e = select.select([sys.stdin], [], [], self.READ_TIMEOUT) requires the file descriptor type which is provided by fileno.

Steps to Reproduce

  1. clone the repository
  2. cd cortexutils
  3. python -m unittest discover
  4. Profit?? ;)

Context (Environment)

The reason this is affecting me is that I am trying to build tests for responders/analyzers that are built on top of this project. This is stopping those tests from running in similar fashion to the tests included in this repository.

@devinbfergy
Copy link
Contributor Author

Based on looking up this specific error. It has to do with how we are checking that stdin stream has information. When that stream is changed to StringIO stream the tests will fail.

@devinbfergy
Copy link
Contributor Author

I found that if you change the check in the worker class to find if there is available input the tests don't fail in that way. Commented code is the old stuff.
#r, w, e = select.select([sys.stdin], [], [], self.READ_TIMEOUT) if not sys.stdin.isatty(): #in r: self._input = json.load(sys.stdin) else: self.error('Input file doesn''t exist')
Now a bunch of the tests fail in other ways. It might be that they are slightly outdated as fpoutput is not apart of the analyzer class.
output = self.analyzer.fpoutput.getvalue().strip() line 116 of the test_suite_analyzer.py file.

@devinbfergy
Copy link
Contributor Author

The above code is failing to format so here is a picture.
image

and

image

@devinbfergy
Copy link
Contributor Author

This fixes the issue with the tests using StringIO to fake sys.stdin. I will put in a pull request with the above suggested fix. Then after that the rest of the test errors can be addressed.

@devinbfergy devinbfergy mentioned this issue Aug 21, 2019
@nadouani nadouani self-assigned this May 14, 2020
@nadouani nadouani added the bug Something isn't working label May 14, 2020
@nadouani nadouani added this to the 2.1.0 milestone Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants