Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during Django test execution: [WinError 206] The filename or extension is too long #24242

Open
Zankroh opened this issue Oct 4, 2024 · 6 comments
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@Zankroh
Copy link

Zankroh commented Oct 4, 2024

Type: Bug

I have a lot of tests in my Django app and if I try to launch them all from the test explorator, I'll had an error.

  1. Run tests from test explorator panel
  2. WinError 206
args:  []
Running Django run tests with command:  ['c:\\Users\\xxxxx\\Projects\\env\\Scripts\\python.exe', 'C:\\Users\\xxxxx\\Projects\\manage.py', 'test', '--testrunner=django_test_runner.CustomExecutionTestRunner',  'test_directory.test_file.TestClass.test_method_1', 'test_directory.test_file.TestClass.test_method_2', ...]
Error during Django test execution: [WinError 206] The filename or extension is too long

The paths of each tests is part of the django unit command.
Command exceed 46500 characters and Windows can not process it (WinError 206).
Maybe it would be great when all tests in a test files is present, replace each path of the tests by the test file.
And if all tests files are present, removing all tests path ?

Example:

tests_directory/
 ├─── test_file.py
 │      ├── TestClass
 │      │      ├─ test_method_1
 │      │      └─ test_method_2
 │      └── TestClass2
 │             ├─ test_method_3
 │             └─ test_method_4
 └─── test_file_2.py
        ├── TestClass3
        │      ├─ test_method_5
        │      └─ test_method_6
        └── TestClass4
               └─ test_method_7

Here, if I want to run all tests from test_file_2.py, command arg should be tests_directory.test_file_2 instead of
tests_directory.test_file_2.TestClass3.test_method_5 tests_directory.test_file_2.TestClass3.test_method_6 tests_directory.test_file_2.TestClass4.test_method_7

Sorry if it's not clear

Extension version: 2024.17.2024100401
VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i7-1260P (16 x 2496)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.70GB (11.53GB free)
Process Argv --crash-reporter-id 96bbfc2b-23da-4f22-8267-b6ead6cf47ab
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyonecf:30548226
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
0ee40948:31013168
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
flighttreat:31134774
wkspc-onlycs-t:31132770
wkspc-ranged-t:31151552
cf971741:31144450
defaultse:31146405
iacca2:31150323
cc771715:31146322

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 4, 2024
@eleanorjboyd
Copy link
Member

Hi! Yes this totally makes sense- I will have to make some adjustments to design to support this- thanks for filing this bug!!

@eleanorjboyd
Copy link
Member

@karthiknadig what is your suggestion here? It is broken because of the way its run here, where it inserts all the test_ids then does a subproccess run. Is there any easier work-around then figuring out all test are selected to run or a folder is selected to run and doing it by that path instead?

print("Running Django run tests with command: ", command)
subprocess_execution = subprocess.run(
command,
capture_output=True,
text=True,
env=env,
)

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 12, 2024
@karthiknadig
Copy link
Member

@eleanorjboyd You might need to do the same thing you did for pytest, send the ids via a file.

@eleanorjboyd
Copy link
Member

@karthiknadig so the issue is that I can call pytest programmatically via pytest.main and sub in the test_ids. With Django to run programmatically it seems I would have to call the steps individually myself like this:

django.setup()

# Get and run the test runner
TestRunner = get_runner(settings)
....

which I think might cause other problems since I am calling Django by hand instead of deferring to the user. Therefore I don't think it is possible to call it in the same way as how I handle pytest.

@karthiknadig
Copy link
Member

Then the alternative is to find common parent to the selected test cases. We will need to do generic parent finding because users can select tests using search.

@eleanorjboyd
Copy link
Member

went ahead and asked in the Django forum for any advice before moving forward with the test-id parent finding route: https://forum.djangoproject.com/t/advice-for-vs-code-testing-implementation/37261

@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants