Skip to content

Commit

Permalink
fix on adding limit
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Jan 6, 2025
1 parent 056c197 commit 17e825d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 9 deletions.
16 changes: 12 additions & 4 deletions python_files/unittestadapter/pvsc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def send_post_request(

if __writer is None:
try:
__writer = open(test_run_pipe, "w", encoding="utf-8", newline="\r\n") # noqa: SIM115, PTH123
__writer = open(test_run_pipe, "wb") # noqa: SIM115, PTH123
except Exception as error:
error_msg = f"Error attempting to connect to extension named pipe {test_run_pipe}[vscode-unittest]: {error}"
print(error_msg, file=sys.stderr)
Expand All @@ -343,9 +343,17 @@ def send_post_request(
data = json.dumps(rpc)
try:
if __writer:
request = f"""content-length: {len(data)}\ncontent-type: application/json\n\n{data}"""
__writer.write(request)
__writer.flush()
request = (
f"""content-length: {len(data)}\r\ncontent-type: application/json\r\n\r\n{data}"""
)
size = 4096
encoded = request.encode("utf-8")
bytes_written = 0
while bytes_written < len(encoded):
print("writing more bytes!")
segment = encoded[bytes_written : bytes_written + size]
bytes_written += __writer.write(segment)
__writer.flush()
else:
print(
f"Connection error[vscode-unittest], writer is None \n[vscode-unittest] data: \n{data} \n",
Expand Down
16 changes: 12 additions & 4 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,8 @@ def send_message(

if __writer is None:
try:
__writer = open(TEST_RUN_PIPE, "w", encoding="utf-8", newline="\r\n") # noqa: SIM115, PTH123
# option B: put this there: , buffering=1024
__writer = open(TEST_RUN_PIPE, "wb") # noqa: SIM115, PTH123 (-1 no ,0 auto,1, int [this is the value of the buffer size])
except Exception as error:
error_msg = f"Error attempting to connect to extension named pipe {TEST_RUN_PIPE}[vscode-pytest]: {error}"
print(error_msg, file=sys.stderr)
Expand All @@ -943,9 +944,16 @@ def send_message(
data = json.dumps(rpc, cls=cls_encoder)
try:
if __writer:
request = f"""content-length: {len(data)}\ncontent-type: application/json\n\n{data}"""
__writer.write(request)
__writer.flush()
request = (
f"""content-length: {len(data)}\r\ncontent-type: application/json\r\n\r\n{data}"""
)
size = 4096
encoded = request.encode("utf-8")
bytes_written = 0
while bytes_written < len(encoded):
segment = encoded[bytes_written : bytes_written + size]
bytes_written += __writer.write(segment)
__writer.flush()
else:
print(
f"Plugin error connection error[vscode-pytest], writer is None \n[vscode-pytest] data: \n{data} \n",
Expand Down
1 change: 0 additions & 1 deletion src/test/testing/common/testingAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ suite('End to End Tests: test adapters', () => {
let callCount = 0;
let failureOccurred = false;
let failureMsg = '';
console.log('EFB: beginning function');
resultResolver._resolveExecution = async (data, _token?) => {
// do the following asserts for each time resolveExecution is called, should be called once per test.
console.log(`pytest execution adapter seg fault error handling \n ${JSON.stringify(data)}`);
Expand Down
103 changes: 103 additions & 0 deletions src/testTestingRootWkspc/largeWorkspace/test_parameterized_subtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,106 @@ def test_even(self):
for i in range(0, 2000):
with self.subTest(i=i):
self.assertEqual(i % 2, 0)


# The repeated tests below are to test the unittest communication as it hits it maximum limit of bytes.


class NumberedTests1(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests2(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests3(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests4(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests5(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests6(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests7(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests8(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests9(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests10(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests11(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests12(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests13(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests14(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests15(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests16(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests17(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests18(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests19(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)


class NumberedTests20(unittest.TestCase):
def test_abc(self):
self.assertEqual(1 % 2, 0)

0 comments on commit 17e825d

Please sign in to comment.