Browse Source

feat: `shore new` now also renders a `src/test` directory (closes #13)

master
Niklas Rosenstein 6 months ago
parent
commit
4011eaf188
Signed by: NiklasRosenstein <rosensteinniklas@gmail.com> GPG Key ID: 06D269B33D25F6C6
3 changed files with 13 additions and 1 deletions
  1. +6
    -1
      src/shore/__main__.py
  2. +1
    -0
      src/shore/templates/package/src/test/{{name}}/__init__.py
  3. +6
    -0
      src/shore/templates/package/src/test/{{name}}/test_some.py

+ 6
- 1
src/shore/__main__.py View File

@@ -187,13 +187,18 @@ def new(**args):

# Render namespace supporting files.
parts = []
for item in name_on_disk.split('.')[:-1]:
for item in name_on_disk.replace('-', '_').split('.')[:-1]:
parts.append(item)
dest = os.path.join(args['directory'], 'src', *parts, '__init__.py')
yield FileToRender(
None,
os.path.normpath(dest),
lambda _, fp: _render_namespace_file(fp))
dest = os.path.join(args['directory'], 'src', 'test', *parts, '__init__.py')
yield FileToRender(
None,
os.path.normpath(dest),
lambda _, fp: fp.write('pass\n'))

# TODO (@NiklasRosenstein): Render the license file if it does not exist.



+ 1
- 0
src/shore/templates/package/src/test/{{name}}/__init__.py View File

@@ -0,0 +1 @@
pass

+ 6
- 0
src/shore/templates/package/src/test/{{name}}/test_some.py View File

@@ -0,0 +1,6 @@

import pytest


def test_something():
...

Loading…
Cancel
Save