Skip to content

Commit

Permalink
3.12 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Jan 10, 2024
1 parent 3235113 commit 41d803e
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions tests/helper/my_path.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
from io import StringIO, TextIOWrapper
from pathlib import Path as _Path
from typing import Optional

from sys import version_info

_path_type = type(_Path())


class Path(_path_type):
_flavour = _path_type._flavour

def __init__(self, *args, does_exist: bool = True, initial_value: Optional[str] = None, **kwargs):
super().__init__()

if hasattr(Path, '_from_parts'):
Path._from_parts(args)
else:
# Pathlib init
drv, root, parts = self._parse_args(args)
self._drv = drv
self._root = root
self._parts = parts
self._init()

# Own Path implementation
self.does_exist: bool = does_exist
self.contents = None
self._create_buffer(initial_value)

def __new__(cls, *args, **kwargs):
return super().__new__(cls, *args)
if version_info < (3, 12):
_flavour = _path_type._flavour

def __init__(self, *args, does_exist: bool = True, initial_value: Optional[str] = None, **kwargs):
super().__init__()

if hasattr(Path, '_from_parts'):
Path._from_parts(args)
else:
# Pathlib init
drv, root, parts = self._parse_args(args)
self._drv = drv
self._root = root
self._parts = parts
self._init()

# Own Path implementation
self.does_exist: bool = does_exist
self.contents = None
self._create_buffer(initial_value)

def __new__(cls, *args, **kwargs):
return super().__new__(cls, *args)

else:
def __init__(self, *args, does_exist: bool = True, initial_value: Optional[str] = None, **kwargs):
super().__init__()
# Own Path implementation
self.does_exist: bool = does_exist
self.contents = None
self._create_buffer(initial_value)

def _create_buffer(self, initial_value: Optional[str] = None):
self.contents = StringIO(initial_value)
Expand Down

0 comments on commit 41d803e

Please sign in to comment.