import os
import subprocess

import pytest


def test_list_subcommands_has_all_scripts():
    """Tests if the output from running `fontbakery --list-subcommands` matches
    the fontbakery scripts within the bin folder."""
    import fontbakery.commands
    commands_dir = os.path.dirname(fontbakery.commands.__file__)

    scripts = [
        f.rstrip(".py").replace("_", "-") for f in os.listdir(commands_dir)
        if (f.endswith(".py") and not f.startswith('_'))
    ]
    subcommands = subprocess.check_output(['fontbakery',
                                           '--list-subcommands']).split()
    assert sorted(scripts) == sorted(subcommands)


def test_command_check_googlefonts():
    """Test if `fontbakery check-googlefonts` can run successfully`."""
    subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])

    with pytest.raises(subprocess.CalledProcessError):
        subprocess.check_output(["fontbakery", "check-googlefonts"])

import os
import subprocess

import pytest


def test_list_subcommands_has_all_scripts():
  """Tests if the output from running `fontbakery --list-subcommands` matches
    the fontbakery scripts within the bin folder."""
  import fontbakery.commands
  commands_dir = os.path.dirname(fontbakery.commands.__file__)

  scripts = [
      f.rstrip(".py").replace("_", "-")
      for f in os.listdir(commands_dir)
      if (f.endswith(".py") and not f.startswith('_'))
  ]
  subcommands = subprocess.check_output(['fontbakery',
                                         '--list-subcommands']).split()
  assert sorted(scripts) == sorted(subcommands)


def test_command_check_googlefonts():
  """Test if `fontbakery check-googlefonts` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-googlefonts"])


def test_command_check_specification():
  """Test if `fontbakery check-specification` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-specification", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-specification"])


def test_command_check_ufo_sources():
  """Test if `fontbakery check-ufo-sources` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-ufo-sources", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-ufo-sources"])

Add usage tests for check-ufo-sources and check-specification
Add usage tests for check-ufo-sources and check-specification

  import os
  import subprocess
  
  import pytest
  
  
  def test_list_subcommands_has_all_scripts():
-     """Tests if the output from running `fontbakery --list-subcommands` matches
+   """Tests if the output from running `fontbakery --list-subcommands` matches
      the fontbakery scripts within the bin folder."""
-     import fontbakery.commands
+   import fontbakery.commands
-     commands_dir = os.path.dirname(fontbakery.commands.__file__)
+   commands_dir = os.path.dirname(fontbakery.commands.__file__)
  
-     scripts = [
+   scripts = [
-         f.rstrip(".py").replace("_", "-") for f in os.listdir(commands_dir)
+       f.rstrip(".py").replace("_", "-")
+       for f in os.listdir(commands_dir)
-         if (f.endswith(".py") and not f.startswith('_'))
+       if (f.endswith(".py") and not f.startswith('_'))
-     ]
+   ]
-     subcommands = subprocess.check_output(['fontbakery',
+   subcommands = subprocess.check_output(['fontbakery',
-                                            '--list-subcommands']).split()
+                                          '--list-subcommands']).split()
-     assert sorted(scripts) == sorted(subcommands)
+   assert sorted(scripts) == sorted(subcommands)
  
  
  def test_command_check_googlefonts():
-     """Test if `fontbakery check-googlefonts` can run successfully`."""
+   """Test if `fontbakery check-googlefonts` can run successfully`."""
-     subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])
+   subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])
  
-     with pytest.raises(subprocess.CalledProcessError):
+   with pytest.raises(subprocess.CalledProcessError):
-         subprocess.check_output(["fontbakery", "check-googlefonts"])
+     subprocess.check_output(["fontbakery", "check-googlefonts"])
  
+ 
+ def test_command_check_specification():
+   """Test if `fontbakery check-specification` can run successfully`."""
+   subprocess.check_output(["fontbakery", "check-specification", "-h"])
+ 
+   with pytest.raises(subprocess.CalledProcessError):
+     subprocess.check_output(["fontbakery", "check-specification"])
+ 
+ 
+ def test_command_check_ufo_sources():
+   """Test if `fontbakery check-ufo-sources` can run successfully`."""
+   subprocess.check_output(["fontbakery", "check-ufo-sources", "-h"])
+ 
+   with pytest.raises(subprocess.CalledProcessError):
+     subprocess.check_output(["fontbakery", "check-ufo-sources"])
+ 
Add usage tests for check-ufo-sources and check-specification
## Code Before:
import os
import subprocess

import pytest


def test_list_subcommands_has_all_scripts():
    """Tests if the output from running `fontbakery --list-subcommands` matches
    the fontbakery scripts within the bin folder."""
    import fontbakery.commands
    commands_dir = os.path.dirname(fontbakery.commands.__file__)

    scripts = [
        f.rstrip(".py").replace("_", "-") for f in os.listdir(commands_dir)
        if (f.endswith(".py") and not f.startswith('_'))
    ]
    subcommands = subprocess.check_output(['fontbakery',
                                           '--list-subcommands']).split()
    assert sorted(scripts) == sorted(subcommands)


def test_command_check_googlefonts():
    """Test if `fontbakery check-googlefonts` can run successfully`."""
    subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])

    with pytest.raises(subprocess.CalledProcessError):
        subprocess.check_output(["fontbakery", "check-googlefonts"])

## Instruction:
Add usage tests for check-ufo-sources and check-specification
## Code After:
import os
import subprocess

import pytest


def test_list_subcommands_has_all_scripts():
  """Tests if the output from running `fontbakery --list-subcommands` matches
    the fontbakery scripts within the bin folder."""
  import fontbakery.commands
  commands_dir = os.path.dirname(fontbakery.commands.__file__)

  scripts = [
      f.rstrip(".py").replace("_", "-")
      for f in os.listdir(commands_dir)
      if (f.endswith(".py") and not f.startswith('_'))
  ]
  subcommands = subprocess.check_output(['fontbakery',
                                         '--list-subcommands']).split()
  assert sorted(scripts) == sorted(subcommands)


def test_command_check_googlefonts():
  """Test if `fontbakery check-googlefonts` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-googlefonts", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-googlefonts"])


def test_command_check_specification():
  """Test if `fontbakery check-specification` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-specification", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-specification"])


def test_command_check_ufo_sources():
  """Test if `fontbakery check-ufo-sources` can run successfully`."""
  subprocess.check_output(["fontbakery", "check-ufo-sources", "-h"])

  with pytest.raises(subprocess.CalledProcessError):
    subprocess.check_output(["fontbakery", "check-ufo-sources"])
