File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ def __init__(self, *segments):
47
47
def __truediv__ (self , other ):
48
48
return Path (self ._path , str (other ))
49
49
50
+ def __rtruediv__ (self , other ):
51
+ return Path (other , self ._path )
52
+
50
53
def __repr__ (self ):
51
54
return f'{ type (self ).__name__ } ("{ self ._path } ")'
52
55
Original file line number Diff line number Diff line change @@ -322,3 +322,14 @@ def test_with_suffix(self):
322
322
self .assertTrue (Path ("foo/test" ).with_suffix (".tar" ) == Path ("foo/test.tar" ))
323
323
self .assertTrue (Path ("foo/bar.bin" ).with_suffix (".txt" ) == Path ("foo/bar.txt" ))
324
324
self .assertTrue (Path ("bar.txt" ).with_suffix ("" ) == Path ("bar" ))
325
+
326
+ def test_rtruediv (self ):
327
+ """Works as of micropython ea7031f"""
328
+ res = "foo" / Path ("bar" )
329
+ self .assertTrue (res == Path ("foo/bar" ))
330
+
331
+ def test_rtruediv_inplace (self ):
332
+ """Works as of micropython ea7031f"""
333
+ res = "foo"
334
+ res /= Path ("bar" )
335
+ self .assertTrue (res == Path ("foo/bar" ))
You can’t perform that action at this time.
0 commit comments