1diff --git a/testsuite/test_api.py b/testsuite/test_api.py
2index 8dde32ff..38e34acf 100644
3--- a/testsuite/test_api.py
4+++ b/testsuite/test_api.py
5@@ -329,7 +329,10 @@ def test_check_nullbytes(self):
6 count_errors = pep8style.input_file('stdin', lines=['\x00\n'])
7
8 stdout = sys.stdout.getvalue()
9- expected = "stdin:1:1: E901 ValueError"
10+ if sys.version_info < (3, 11, 4):
11+ expected = "stdin:1:1: E901 ValueError"
12+ else:
13+ expected = "stdin:1:1: E901 SyntaxError: source code string cannot contain null bytes" # noqa: E501
14 self.assertTrue(stdout.startswith(expected),
15 msg='Output %r does not start with %r' %
16 (stdout, expected))