Skip to content

Commit

Permalink
✨ Format accessors for enumerating
Browse files Browse the repository at this point in the history
  • Loading branch information
vokimon committed Oct 9, 2023
1 parent f1c4227 commit a98964c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
16 changes: 16 additions & 0 deletions wavefile/wavefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ def isSupported(self):
def info(self):
return formatDescription(self.value)

@classmethod
def common(cls):
return commonFormats()

@classmethod
def all(cls):
return allFormats()

@classmethod
def major(cls):
return majorFormats()

@classmethod
def subtypes(cls):
return subtypeFormats()


WAV = 0x010000 # Microsoft WAV format (little endian default).
AIFF = 0x020000 # Apple/SGI AIFF format (big endian).
Expand Down
25 changes: 25 additions & 0 deletions wavefile/wavefile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ def setUp(self):
import pkg_resources
self.sfversion = wavefile._lib.sf_version_string().decode()
self.version = v(self.sfversion[len('libsndfile-'):])
self.maxDiff = None

def assertFormatListEqual(self, data, expected):
rendered = ''.join(
Expand Down Expand Up @@ -985,4 +986,28 @@ def test_info_major_badone(self):
)


def test_format_all__equal_allFormats(self):
self.assertEqual(
list(wavefile.Format.all()),
list(wavefile.allFormats()),
)

def test_format_common__equal_commonFormats(self):
self.assertEqual(
list(wavefile.Format.common()),
list(wavefile.commonFormats()),
)

def test_format_major__equal_majorFormats(self):
self.assertEqual(
list(wavefile.Format.major()),
list(wavefile.majorFormats()),
)

def test_format_subtypes__equal_subtypesFormats(self):
self.assertEqual(
list(wavefile.Format.subtypes()),
list(wavefile.subtypeFormats()),
)


0 comments on commit a98964c

Please sign in to comment.