File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 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):
4747 def __truediv__ (self , other ):
4848 return Path (self ._path , str (other ))
4949
50+ def __rtruediv__ (self , other ):
51+ return Path (other , self ._path )
52+
5053 def __repr__ (self ):
5154 return f'{ type (self ).__name__ } ("{ self ._path } ")'
5255
Original file line number Diff line number Diff line change @@ -322,3 +322,14 @@ def test_with_suffix(self):
322322 self .assertTrue (Path ("foo/test" ).with_suffix (".tar" ) == Path ("foo/test.tar" ))
323323 self .assertTrue (Path ("foo/bar.bin" ).with_suffix (".txt" ) == Path ("foo/bar.txt" ))
324324 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