@@ -3093,6 +3093,64 @@ def test_root_name(self, alpharep):
30933093 root = zipfile .Path (alpharep )
30943094 assert root .name == 'alpharep.zip' == root .filename .name
30953095
3096+ @pass_alpharep
3097+ def test_suffix (self , alpharep ):
3098+ """
3099+ The suffix of the root should be the suffix of the zipfile.
3100+ The suffix of each nested file is the final component's last suffix, if any.
3101+ Includes the leading period, just like pathlib.Path.
3102+ """
3103+ root = zipfile .Path (alpharep )
3104+ assert root .suffix == '.zip' == root .filename .suffix
3105+
3106+ b = root / "b.txt"
3107+ assert b .suffix == ".txt"
3108+
3109+ c = root / "c" / "filename.tar.gz"
3110+ assert c .suffix == ".gz"
3111+
3112+ d = root / "d"
3113+ assert d .suffix == ""
3114+
3115+ @pass_alpharep
3116+ def test_suffixes (self , alpharep ):
3117+ """
3118+ The suffix of the root should be the suffix of the zipfile.
3119+ The suffix of each nested file is the final component's last suffix, if any.
3120+ Includes the leading period, just like pathlib.Path.
3121+ """
3122+ root = zipfile .Path (alpharep )
3123+ assert root .suffixes == ['.zip' ] == root .filename .suffixes
3124+
3125+ b = root / 'b.txt'
3126+ assert b .suffixes == ['.txt' ]
3127+
3128+ c = root / 'c' / 'filename.tar.gz'
3129+ assert c .suffixes == ['.tar' , '.gz' ]
3130+
3131+ d = root / 'd'
3132+ assert d .suffixes == []
3133+
3134+ e = root / '.hgrc'
3135+ assert e .suffixes == []
3136+
3137+ @pass_alpharep
3138+ def test_stem (self , alpharep ):
3139+ """
3140+ The final path component, without its suffix
3141+ """
3142+ root = zipfile .Path (alpharep )
3143+ assert root .stem == 'alpharep' == root .filename .stem
3144+
3145+ b = root / "b.txt"
3146+ assert b .stem == "b"
3147+
3148+ c = root / "c" / "filename.tar.gz"
3149+ assert c .stem == "filename.tar"
3150+
3151+ d = root / "d"
3152+ assert d .stem == "d"
3153+
30963154 @pass_alpharep
30973155 def test_root_parent (self , alpharep ):
30983156 root = zipfile .Path (alpharep )
0 commit comments