Repository: audreyr/cookiecutter
Pull request #528 (2015-09-24 13:41:15)

Increase yaml error verbosity
Merge @vaab's changes  and extend the corresponding test.

Resolve #378 



codecov-io: ## [Current coverage][1] is `99.15%`
> Merging **#528** into **master** will not affect coverage as of [`4a09ed1`][3]


```diff
@@            master    #528   diff @@
======================================
  Files           13      13       
  Stmts          476     476       
  Branches         0       0       
  Methods          0       0       
======================================
  Hit            472     472       
  Partial          0       0       
  Missed           4       4       
```

> Review entire [Coverage Diff][4] as of [`4a09ed1`][3]


-----
### [Uncovered Suggestions][2]

1. `+0.42%` via [...ookiecutter/utils.py#27...28](https://codecov.io/github/audreyr/cookiecutter/cookiecutter/utils.py?ref=4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b#27) 
1. `+0.42%` via [...iecutter/__init__.py#15...16](https://codecov.io/github/audreyr/cookiecutter/cookiecutter/__init__.py?ref=4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b#15) 


[1]: https://codecov.io/github/audreyr/cookiecutter?ref=4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b
[2]: https://codecov.io/github/audreyr/cookiecutter/features/suggestions?ref=4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b
[3]: https://codecov.io/github/audreyr/cookiecutter/commit/4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b
[4]: https://codecov.io/github/audreyr/cookiecutter/compare/6c8ff309173fd21dacbfe6ec6325922c1eff148c...4a09ed1a28aed61e7d963ddeabe2120d5e5d4f2b

> Powered by [Codecov](https://codecov.io). Updated on successful CI builds.
vaab: thanks for this review and merge.

Patch:
diff --git a/cookiecutter/config.py b/cookiecutter/config.py
index 840fea0..3418a96 100755
--- a/cookiecutter/config.py
+++ b/cookiecutter/config.py
@@ -41,9 +41,12 @@ def get_config(config_path):
     with io.open(config_path, encoding='utf-8') as file_handle:
         try:
             yaml_dict = yaml.safe_load(file_handle)
-        except yaml.scanner.ScannerError:
+        except yaml.scanner.ScannerError as e:
             raise InvalidConfiguration(
-                '{0} is no a valid YAML file'.format(config_path))
+                '{0} is not a valid YAML file: line {1}: {2}'.format(
+                    config_path,
+                    e.problem_mark.line,
+                    e.problem))
 
     config_dict = copy.copy(DEFAULT_CONFIG)
     config_dict.update(yaml_dict)


Test patch:
diff --git a/tests/test_get_config.py b/tests/test_get_config.py
index f45d13e..ac3e6a3 100644
--- a/tests/test_get_config.py
+++ b/tests/test_get_config.py
@@ -51,9 +51,15 @@ def test_invalid_config():
     """
     An invalid config file should raise an `InvalidConfiguration` exception.
     """
-    with pytest.raises(InvalidConfiguration):
+    with pytest.raises(InvalidConfiguration) as excinfo:
         config.get_config('tests/test-config/invalid-config.yaml')
 
+    expected_error_msg = (
+        'tests/test-config/invalid-config.yaml is not a valid YAML file: '
+        'line 1: mapping values are not allowed here'
+    )
+    assert str(excinfo.value) == expected_error_msg
+
 
 def test_get_config_with_defaults():
     """