Coverage for /opt/obspy/update-docs/src/obspy/obspy/xseed/tests/test_blockettes : 91%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
""" Test cases for all blockettes. """ # directory where the test files are located
""" A wrong blockette length should raise an exception. """ # create a blockette 054 which is way to long
""" Parses the test definition file and creates a list of it. """ # Create a new empty list to store all information of the test in it. # Now read the corresponding file and parse it. # Helper variable to parse the file. Might be a little bit slow but its # just for tests. # Skip unnecessary content. else: # If new example number append new list. # Append new list to the current example of the list. The # list contains the type of the example. # Filter out any empty/commentary lines still remaining and also # set cur_stat to None. cur_stat = None continue # Simplify and Validate the list.
""" Takes an examples list and combines the XSEED strings and validates the list. Afterwards in creates a list containing a dictionary for each example set. """ # Loop over each example: msg = 'At least one SEED and XSEED string for each examples.' raise Exception(msg) # Exactly one SEED string needed. msg = 'Only one SEED string per example!' raise Exception(msg) # Some other stuff is not tested! Please be careful and adhere to # the format rules for writing blockette tests. # Loop over each type in the example and differentiate between # SEED and not SEED types. # Nothing to do here except to remove the line ending. # Remove spaces and line endings. temp_string = temp_string[:-2] # Combine all XSEED strings to one large string. The weird # PLACEHOLDER syntax assures that flat fields are parsed # correctly because you need to have a space between them. # Now create a dictionary for each example.
""" Takes everything in the prepared list and tests the SEED/XSEED conversion for all given formats. """ # Another loop over all examples. # Create several blockette instances # One to read from SEED and one for each XSEED version.
# prepare SEED
# prepare XSEED # loop over all combinations # conversion to SEED errmsg % (blkt_number, 'SEED', key1, seed, versions['SEED']['data'])) xseed_version=blkt2['version'])) errmsg % (blkt_number, 'XSEED', key2, xseed, blkt2['data']))
""" Tests all Blockettes. """ # Loop over all files in the blockette-tests directory. # Get blockette number. # Check whether the blockette class can be loaded. except: msg = 'Failed to import blockette', blkt_number raise ImportError(msg) # Parse the file. # The last step is to actually test the conversions to and from # SEED/XSEED for every example in every direction.
if __name__ == '__main__': unittest.main(defaultTest='suite') |