File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -2558,13 +2558,21 @@ def test_expanduser(self):
2558
2558
othername = username
2559
2559
otherhome = userhome
2560
2560
2561
+ fakename = 'fakeuser'
2562
+ # This user can theoretically exist on a test runner. Create unique name:
2563
+ try :
2564
+ while pwd .getpwnam (fakename ):
2565
+ fakename += '1'
2566
+ except KeyError :
2567
+ pass # Non-existent name found
2568
+
2561
2569
p1 = P ('~/Documents' )
2562
- p2 = P ('~' + username + ' /Documents' )
2563
- p3 = P ('~' + othername + ' /Documents' )
2564
- p4 = P ('../~' + username + ' /Documents' )
2565
- p5 = P ('/~' + username + ' /Documents' )
2570
+ p2 = P (f'~ { username } /Documents' )
2571
+ p3 = P (f'~ { othername } /Documents' )
2572
+ p4 = P (f '../~{ username } /Documents' )
2573
+ p5 = P (f '/~{ username } /Documents' )
2566
2574
p6 = P ('' )
2567
- p7 = P ('~fake800813user /Documents' )
2575
+ p7 = P (f'~ { fakename } /Documents' )
2568
2576
2569
2577
with os_helper .EnvironmentVarGuard () as env :
2570
2578
env .pop ('HOME' , None )
Original file line number Diff line number Diff line change
1
+ Now ``fakename `` in ``test_pathlib.PosixPathTest.test_expanduser `` is checked
2
+ to be non-existent.
You can’t perform that action at this time.
0 commit comments