{"action":"created","issue":{"url":"https://api.github.com/repos/Gallopsled/pwntools/issues/1407","repository_url":"https://api.github.com/repos/Gallopsled/pwntools","labels_url":"https://api.github.com/repos/Gallopsled/pwntools/issues/1407/labels{/name}","comments_url":"https://api.github.com/repos/Gallopsled/pwntools/issues/1407/comments","events_url":"https://api.github.com/repos/Gallopsled/pwntools/issues/1407/events","html_url":"https://github.com/Gallopsled/pwntools/issues/1407","id":549879917,"node_id":"MDU6SXNzdWU1NDk4Nzk5MTc=","number":1407,"title":"Testing broken in VS Code (Inappropriate ioctl for device)","user":{"login":"EricWardner","id":6416394,"node_id":"MDQ6VXNlcjY0MTYzOTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6416394?v=4","gravatar_id":"","url":"https://api.github.com/users/EricWardner","html_url":"https://github.com/EricWardner","followers_url":"https://api.github.com/users/EricWardner/followers","following_url":"https://api.github.com/users/EricWardner/following{/other_user}","gists_url":"https://api.github.com/users/EricWardner/gists{/gist_id}","starred_url":"https://api.github.com/users/EricWardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricWardner/subscriptions","organizations_url":"https://api.github.com/users/EricWardner/orgs","repos_url":"https://api.github.com/users/EricWardner/repos","events_url":"https://api.github.com/users/EricWardner/events{/privacy}","received_events_url":"https://api.github.com/users/EricWardner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2020-01-14T23:35:09Z","updated_at":"2020-01-14T23:39:07Z","closed_at":null,"author_association":"NONE","body":"I've been playing around with VS Code and the Windows Subsystem for Linux trying to get some of my projects working with that environment. \r\n\r\nI'm having an issue that I think might be related to the VS Code output terminal. Here's an example that breaks when I try to run tests from from inside the IDE's built in testing framework but not when I run from the IDE command line. I imagine it has something to do with the way VS code imports the module into it's own testing framework. \r\n\r\n## Code That Breaks \r\n```python\r\nimport unittest\r\nfrom pwn import *\r\n\r\nclass TestExercise(unittest.TestCase):\r\n    def test_remote(self):\r\n        conn = remote('ftp.ubuntu.com',21)\r\n        resp = conn.recvline().decode()\r\n        print(resp)\r\n        self.assertIn(\"220\", resp)\r\n    \r\nif __name__ == '__main__':\r\n    unittest.main()\r\n```\r\n\r\n## Thrown Exception\r\n\r\n```\r\nImportError: Failed to import test module: runtests\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.6/unittest/loader.py\", line 428, in _find_test_path\r\n    module = self._get_module_from_name(name)\r\n  File \"/usr/lib/python3.6/unittest/loader.py\", line 369, in _get_module_from_name\r\n    __import__(name)\r\n  File \"*****/projects/random_pwntools_test/runtests.py\", line 2, in <module>\r\n    from pwn import *\r\n  File \"*****/.local/lib/python3.6/site-packages/pwn/__init__.py\", line 6, in <module>\r\n    pwnlib.args.initialize()\r\n  File \"*****/.local/lib/python3.6/site-packages/pwnlib/args.py\", line 209, in initialize\r\n    term.init()\r\n  File \"*****/.local/lib/python3.6/site-packages/pwnlib/term/__init__.py\", line 75, in init\r\n    term.init()\r\n  File \"*****/.local/lib/python3.6/site-packages/pwnlib/term/term.py\", line 102, in init\r\n    setupterm()\r\n  File \"*****/.local/lib/python3.6/site-packages/pwnlib/term/term.py\", line 74, in setupterm\r\n    update_geometry()\r\n  File \"*****/.local/lib/python3.6/site-packages/pwnlib/term/term.py\", line 46, in update_geometry\r\n    hw = fcntl.ioctl(fd.fileno(), termios.TIOCGWINSZ, '1234')\r\nOSError: [Errno 25] Inappropriate ioctl for device\r\n```\r\n\r\n### Hacky Fixes\r\nJust shimming out the initialize function works for my specific use case. But that probably kills other terminal functionality I might want in the future? (and it makes command line output way less pretty)\r\n```python\r\nimport pwnlib.args\r\npwnlib.args.initialize = lambda: None\r\n```\r\n\r\n### Resources\r\nhttps://code.visualstudio.com/docs/python/testing#_test-discovery"},"comment":{"url":"https://api.github.com/repos/Gallopsled/pwntools/issues/comments/574425699","html_url":"https://github.com/Gallopsled/pwntools/issues/1407#issuecomment-574425699","issue_url":"https://api.github.com/repos/Gallopsled/pwntools/issues/1407","id":574425699,"node_id":"MDEyOklzc3VlQ29tbWVudDU3NDQyNTY5OQ==","user":{"login":"EricWardner","id":6416394,"node_id":"MDQ6VXNlcjY0MTYzOTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6416394?v=4","gravatar_id":"","url":"https://api.github.com/users/EricWardner","html_url":"https://github.com/EricWardner","followers_url":"https://api.github.com/users/EricWardner/followers","following_url":"https://api.github.com/users/EricWardner/following{/other_user}","gists_url":"https://api.github.com/users/EricWardner/gists{/gist_id}","starred_url":"https://api.github.com/users/EricWardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricWardner/subscriptions","organizations_url":"https://api.github.com/users/EricWardner/orgs","repos_url":"https://api.github.com/users/EricWardner/repos","events_url":"https://api.github.com/users/EricWardner/events{/privacy}","received_events_url":"https://api.github.com/users/EricWardner/received_events","type":"User","site_admin":false},"created_at":"2020-01-14T23:39:07Z","updated_at":"2020-01-14T23:39:07Z","author_association":"NONE","body":"I guess it's probably not a pwntools issue \r\n\r\n### Also Breaks\r\n```\r\nimport unittest\r\nimport sys\r\nimport termios\r\nimport fcntl\r\n\r\nclass TestExercise(unittest.TestCase):\r\n    def test_remote(self):\r\n        fd = sys.stdout\r\n        hw = fcntl.ioctl(fd.fileno(), termios.TIOCGWINSZ, '1234')\r\n        print(hw)\r\n    \r\nif __name__ == '__main__':\r\n    unittest.main()\r\n```"}}
{"actor":{"display_login":"EricWardner"}}