summaryrefslogtreecommitdiff
path: root/websocket/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix a few errors found by pytype. (#906)HEADmasterTimo Ewalds2023-05-121-1/+1
| | | | | | | | | | | | | | | | | | * Fix pytype error: File "websocket/_wsdump.py", line 107, in <module>: Overriding method signature mismatch [signature-mismatch] Base signature: 'def code.InteractiveConsole.raw_input(self, prompt: str = ...) -> str'. Subclass signature: 'def RawInput.raw_input(self, prompt) -> Any'. Parameter 'prompt' must have a default value. * Fix pytype error: File "websocket/tests/echo-server.py", line 18, in main: Function Serve.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, ws_handler, host, port: Optional[int] = ..., ...) Actually passed: (self, ws_handler, host, port: str) * Fix undefined variable error found by pytype: File "compliance/test_fuzzingclient.py", line 57, in <module>: Name 'case' is not defined [name-error]
* Remove incorrect commentengn33r2023-01-261-1/+0
|
* Refactor and fix reconnect and ping (#862)j-a-n2023-01-261-0/+85
| | | | | | | | | | | | | | | | | | | | * Refactor and fix reconnect and ping - Dispatcher: do not reconnect in loop - Avoid reconnect in recursion and hit maximum recursion depth - Close websocket before reconnect to avoid unclosed ssl.SSLSocket warnings - Start ping thread on socket connect - Stop ping thread on socket disconnect - Add reconnect test - Add callback exception test * Remove duplicate function * Also check passed app in testCallbackException * Test exception in callback method Co-authored-by: Jan Schneider <j.schneider@uib.de> Co-authored-by: engn33r <engn33r@users.noreply.github.com>
* remove problematic CI test URLengn33r2023-01-261-7/+8
|
* create_dispatcher() w/ is_ssl determined by url instead of sslopt (#875)bubbleboy142022-11-031-1/+1
| | | | | | | | | | | * create_dispatcher() w/ is_ssl determined by url instead of sslopt * added .lower() (per @rm-you's suggestion) * create_dispatcher() w/ parse_url()-derived is_ssl * Fix failing test, missing wss Co-authored-by: engn33r <engn33r@users.noreply.github.com>
* Remove broken websockets.org links from documentationengn33r2022-10-251-1/+1
|
* fix for stack growth on reconnect (#854)bubbleboy142022-09-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rel example * tweaked rel example for linter * added rel note to examples.rst * slightly more compact example * added example header * matched wording * _socket.recv(): _recv() except socket.error - changed or to and; added except TimeoutError - raise WebSocketTimeoutException * _app - custom dispatcher check_callback() integration (and fixed pyevent compatibility): WrappedDispatcher (for use with generic event dispatchers such as pyevent and rel); create_dispatcher() accepts dispatcher kwarg (default None), and if it is specified, returns a WrappedDispatcher; use create_dispatcher() (passing specified dispatcher if any) every time (regardless of dispatcher specification) * Add clarifying comment, rerun CI tests * Add space to make linter happy * working reconnect * rmed logs * added _logging.warning() disconnected/reconnected notifications to handleDisconnect() * moved connect notification and dispatcher.read() (if doread kwarg [default False] is True) to setSock() (prevents those lines from running on ConnectionRefusedError) * run_forever(): reconnect kwarg now specifies sleep() time (defualt 5) * handleDisconnect(): fixed log msg * run_forever() refactor: stabilized stack frame count (at least in rel mode); added stack frame count to disconnect (warning) log; grossly oversimplified ;) * dispatcher simplification via DispatcherBase and DispatcherBase/WrappedDispatcher.timeout() * _logging: info(); enableTrace() supports level kwarg (default "DEBUG") * handleDisconnect() uses info() log * Fix linting errors * moved timeout() from Dispatcher to DispatcherBase (thus also applying to SSLDispatcher) * reconnect()s for DispatcherBase (uses while loop) and WrappedDispatcher (uses timeout()); setSock() reconnecting (default False) kwarg - if reconnecting, skip handleDisconnect(); handleDisconnect() calls dispatcher.reconnect() * custom_dispatcher switch in handleDisconnect() * WrappedDispatcher constructor registers keyboard interrupt signal * DispatcherBase.reconnect(): wrapped while loop in KeyboardInterrupt try/except * fixed lint errors * _app: RECONNECT (default 5) and setReconnect() setter; WebSocketApp.run_forever() reconnect kwarg defaults to RECONNECT * tests.test_app: ws.setReconnect(0) (may fix test stall issue) * oops, added setReconnect import to websocket __init__ * blank line for linter * linter line * added rel to setup extras_require{test}[] * adjusted testRunForeverDispatcher() to use rel (including dispatch()) * setup: moved rel dep from extras_require{test}[] to tests_require[] * meh trying install_requires[] (tests_require[] depped??) * set RECONNECT (run_forever() reconnect kwarg default) to 0 (can be altered with setReconnect()) to preserve old (non-reconnecting) default behavior for existing integrations * rmed rel from install_requires[] (only added for tests, and was not working...) * test_app: rmed ws.setReconnect(0) (0 is new default) * run_forever() reconnect->RECONNECT fallback in func instead of kwarg default * test_app: disabled rel import (unsure how to set up test dependency) and testRunForeverDispatcher() (also not working previously afaik) * linter fixes * linter comment spaces * run_forever() returns False to pass testRunForeverTeardownCleanExit test * run_forever() returns False unless error (handleDisconnect() changes to True before calling on_error callback) * rval->self.has_errored Co-authored-by: engn33r <engn33r@users.noreply.github.com>
* Allow passing `http_proxy_timeout` to `run_forever`. (#842)Adam Wojtczak2022-08-241-6/+6
| | | | | | | | | | * Allow passing `http_proxy_timeout` to `run_forever` * Normalize docstring * fix flake8 lint Co-authored-by: Adam Wojtczak <adam.wojtczak@cybercare.cc> Co-authored-by: engn33r <engn33r@users.noreply.github.com>
* Linting improvements, improved flake8 linting CI cmdengn33r2022-02-256-44/+36
|
* fix!: `WebSocketApp.run_forever()` returning `None` after `close()` is ↵FujiApple2022-02-252-3/+36
| | | | | | | | | | | | | called (#788) * fix!: `WebSocketApp.run_forever()` returning `None` after `close()` is called BREAKING CHANGE: the return value of `WebSocketApp.run_forever()` will no longer return the (undocumented) `None` value. * fix(tests): replace the defunct `wss://stream.meetup.com/2/rsvps` with `wss://api.bitfinex.com/ws/2` in several tests * test: added two new local server tests to cover the changes in #785 * Remove newline to fix lint error
* Replace deprecated stream.meetup.com, echo.websocket.org endpoint URLsengn33r2022-02-252-30/+30
|
* Update copyright year to 2022engn33r2021-12-316-6/+6
|
* Minor test improvements for better code coverageengn33r2021-12-133-1/+23
|
* Revert 998c496, fix #769engn33r2021-12-071-0/+42
|
* Fix #752 remove keep_running variable in library and testsengn33r2021-11-261-42/+0
|
* Fix testConnect test case with tuple of errorsengn33r2021-11-261-4/+4
|
* Fix SSL test errors from ssl.PROTOCOL_TLS_CLIENT changeengn33r2021-11-222-4/+2
|
* Fix #760 Replace deprecated ssl.PROTOCOL_TLS with ssl.PROTOCOL_TLS_CLIENTengn33r2021-11-221-1/+1
|
* Use bytes literal (#751)谭九鼎2021-11-221-1/+1
| | | | | * Use bytes literal instead of bytes() * Add UTF-8 suggestion to comments
* Py2->3: simplify class definition (#750)谭九鼎2021-10-203-3/+3
| | | Remove implied and redundant object class type declarations
* Improve usage of LOCAL_WS_SERVER_PORTengn33r2021-08-143-7/+7
|
* Improve unit tests with LOCAL_WS_SERVER_PORT variableengn33r2021-08-137-32/+35
|
* Fix python-socks dependency and replace echo.websocket.org in testsengn33r2021-08-114-14/+41
| | | | | | | | The recent addition of python-socks required it to be a dependency. This was mentioned in #728. Additional changes were made to prevent python-socks from becoming a required dependency for every install, so now it is only required for SOCKS proxy usage. Additionally, because echo.websockets.org was experiencing downtime issues during this fix, echo.websockets.org was replaced in unit tests with a local echo server from the Python websockets library. This should speed up tests, avoid test errors cause by external website downtime, and reduce traffic to echo.websocket.org caused by this project.
* Transition from LGPL 2.1 license to Apache 2.0 - fix #697engn33r2021-08-106-78/+66
|
* Revert #417 and reimplement proxy support with python-socksengn33r2021-08-101-17/+25
| | | | | | | | | | | | Due to the ongoing license change process in #697, PR #417 from @jhtitor needed to be removed. PR #417 added SOCKS proxy support using PySocks, which is the most popular Python SOCKS proxy and is used by libraries such as 'requests' and 'urllib3'. However, as of mid-2021, PySocks has not seen any activity since Sep 2019 and has several open issues. Because PySocks does not appear to be maintained and has no forks that are actively trying to replace the old repository, python-socks may be a better choice going forward. Although python-socks is a newer project, it has good code coverage and recent commits from earlier this year (2021).
* Unquote username and password in proxy from environment (#723)Richard2021-07-161-0/+4
| | | | | This fixes e.g. credentials containing a `@` escaped as `%40`. Closes #722.
* Minor code coverage unit test improvementengn33r2021-06-082-4/+15
|
* Replace deprecated ssl.PROTOCOL_SSLv23 with ssl.PROTOCOL_TLSengn33r2021-06-031-1/+1
|
* Add code coverage for PR #698engn33r2021-05-311-0/+1
|
* Fix CI errorsengn33r2021-05-301-1/+1
|
* Add working HTTP proxy unit testsengn33r2021-05-301-0/+11
|
* Fix proxy exceptions in unit testsengn33r2021-05-301-3/+3
|
* Revert exception handling from 13e83b4engn33r2021-05-211-1/+1
|
* Remove testSSLopt unit test timeout to avoid exceptionengn33r2021-05-171-1/+1
|
* Try to resolve test_http.py testSSLopt Mac errorengn33r2021-05-171-2/+2
|
* Improve _app.py, _http.py unit testsengn33r2021-05-172-4/+24
|
* Fix unit test for raising error in close()engn33r2021-05-172-5/+3
|
* Improve _abnf.py, _cookiejar.py unit test coverageengn33r2021-05-162-10/+14
|
* Improve _abnf.py and _http.py test coverageengn33r2021-05-162-22/+44
|
* Add test case with sslopt settingsengn33r2021-05-151-3/+6
|
* Improve unittest code coverageengn33r2021-05-152-6/+38
|
* Minor _core.py test coverage improvementengn33r2021-05-121-1/+4
|
* Comment out unittest that fails on MacOSengn33r2021-05-121-1/+2
|
* Improve test coverage of _http.pyengn33r2021-05-061-2/+38
|
* Add status code examples to docs, improve unit testsengn33r2021-05-062-25/+58
|
* Remove six dependency and transition related code to Python3engn33r2021-05-051-4/+1
|
* Fix lint errorengn33r2021-05-051-0/+1
|
* Fix #685 unittest requires internetengn33r2021-05-051-1/+4
|
* First pass removing Python 2 code, mostly six dependencyengn33r2021-05-045-86/+43
|
* PEP8 style compliance fixesengn33r2021-05-045-28/+8
|