Beispiel #1
0
    def test_register_archive_format(self):

        self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          [(1, 2), (1, 2, 3)])

        register_archive_format('xxx', lambda: x, [(1, 2)], 'xxx file')
        formats = [name for name, params in get_archive_formats()]
        self.assertIn('xxx', formats)

        unregister_archive_format('xxx')
        formats = [name for name, params in get_archive_formats()]
        self.assertNotIn('xxx', formats)
Beispiel #2
0
    def test_register_archive_format(self):

        self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          1)
        self.assertRaises(TypeError, register_archive_format, 'xxx', lambda: x,
                          [(1, 2), (1, 2, 3)])

        register_archive_format('xxx', lambda: x, [(1, 2)], 'xxx file')
        formats = [name for name, params in get_archive_formats()]
        self.assertIn('xxx', formats)

        unregister_archive_format('xxx')
        formats = [name for name, params in get_archive_formats()]
        self.assertNotIn('xxx', formats)
Beispiel #3
0
def show_formats():
    """Print all possible values for the 'formats' option (used by
    the "--help-formats" command-line option).
    """
    from distutils2.fancy_getopt import FancyGetopt
    formats = sorted(('formats=' + name, None, desc)
                     for name, desc in get_archive_formats())
    FancyGetopt(formats).print_help(
        "List of available source distribution formats:")
Beispiel #4
0
def show_formats():
    """Print all possible values for the 'formats' option (used by
    the "--help-formats" command-line option).
    """
    from distutils2.fancy_getopt import FancyGetopt
    formats = sorted(('formats=' + name, None, desc)
                     for name, desc in get_archive_formats())
    FancyGetopt(formats).print_help(
        "List of available source distribution formats:")
    def test_show_formats(self):
        with captured_stdout() as stdout:
            show_formats()
        stdout = stdout.getvalue()

        # the output should be a header line + one line per format
        num_formats = len(get_archive_formats())
        output = [line for line in stdout.split('\n')
                  if line.strip().startswith('--formats=')]
        self.assertEqual(len(output), num_formats)
    def test_show_formats(self):
        saved = sys.stdout
        sys.stdout = StringIO()
        try:
            show_formats()
            stdout = sys.stdout.getvalue()
        finally:
            sys.stdout = saved

        # the output should be a header line + one line per format
        num_formats = len(get_archive_formats())
        output = [line for line in stdout.split('\n')
                  if line.strip().startswith('--formats=')]
        self.assertEqual(len(output), num_formats)
Beispiel #7
0
 def _check_archive_formats(self, formats):
     supported_formats = [name for name, desc in get_archive_formats()]
     for format in formats:
         if format not in supported_formats:
             return format
     return None
Beispiel #8
0
 def _check_archive_formats(self, formats):
     supported_formats = [name for name, desc in get_archive_formats()]
     for format in formats:
         if format not in supported_formats:
             return format
     return None