Skip to content

Commit

Permalink
Use the raw string notation for regular expression patterns.
Browse files Browse the repository at this point in the history
Addressing
/tmp/tests/t4_shell.py:26: SyntaxWarning: invalid escape sequence '\['
  self.assertRegex(data, b"^Last login: |\[root@.+ ~\]# $")
  • Loading branch information
adelton committed Feb 17, 2024
1 parent 9044b23 commit 7de33bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Run tests in the container
run: docker exec python-libssh python3 setup.py test
- name: Run tests with installed rpm
run: docker exec python-libssh bash -c 'cp -rp tests /tmp/tests && cd /tmp/tests && for i in *.py ; do python3 $i ; done'
run: docker exec python-libssh bash -c 'cp -rp tests /tmp/tests && cd /tmp/tests && for i in *.py ; do python3 -Werror $i ; done'
6 changes: 3 additions & 3 deletions tests/t4_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def test1_shell(self):
self.assertIsInstance(channel, libssh.Channel)

data = channel.read_nonblocking()
self.assertRegex(data, b"^$|^Last login: ")
self.assertRegex(data.decode('utf-8'), r"^$|^Last login: ")
sleep(1)
data = channel.read_nonblocking()
self.assertRegex(data, b"^Last login: |\[root@.+ ~\]# $")
self.assertRegex(data.decode('utf-8'), r"^Last login: |\[root@.+ ~\]# $")

channel.write(b"echo hello world\n")
sleep(1)
data = channel.read_nonblocking()
self.assertRegex(data, b"^echo hello world\r\nhello world\r\n")
self.assertRegex(data.decode('utf-8'), r"^echo hello world\r\nhello world\r\n")

session.disconnect()

Expand Down

0 comments on commit 7de33bb

Please sign in to comment.