mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
put fixtures into conftest
This commit is contained in:
@@ -7,19 +7,15 @@ import pytest
|
||||
from blag import blag
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def outdir():
|
||||
with TemporaryDirectory() as dir:
|
||||
yield dir
|
||||
|
||||
|
||||
def test_generate_feed(outdir):
|
||||
def test_generate_feed(tempdir):
|
||||
outdir = f'{tempdir}/build'
|
||||
articles = []
|
||||
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
||||
assert os.path.exists(f'{outdir}/atom.xml')
|
||||
|
||||
|
||||
def test_feed(outdir):
|
||||
def test_feed(tempdir):
|
||||
outdir = f'{tempdir}/build'
|
||||
articles = [
|
||||
[
|
||||
'dest1.html',
|
||||
@@ -66,7 +62,8 @@ def test_feed(outdir):
|
||||
assert '<link href="https://example.com/dest2.html"' in feed
|
||||
|
||||
|
||||
def test_generate_feed_with_description(outdir):
|
||||
def test_generate_feed_with_description(tempdir):
|
||||
outdir = f'{tempdir}/build'
|
||||
# if a description is provided, it will be used as the summary in
|
||||
# the feed, otherwise we simply use the title of the article
|
||||
articles = [[
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from tempfile import TemporaryDirectory
|
||||
from blag import devserver
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tempdir():
|
||||
with TemporaryDirectory() as dir:
|
||||
yield dir
|
||||
|
||||
|
||||
def test_get_last_modified(tempdir):
|
||||
# take initial time
|
||||
t1 = devserver.get_last_modified([tempdir])
|
||||
|
||||
@@ -1,46 +1,5 @@
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from blag import blag
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def environment():
|
||||
site = {
|
||||
'base_url': 'site base_url',
|
||||
'title': 'site title',
|
||||
'description': 'site description',
|
||||
'author': 'site author',
|
||||
}
|
||||
env = blag.environment_factory(globals_=dict(site=site))
|
||||
yield env
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page_template(environment):
|
||||
yield environment.get_template('page.html')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def article_template(environment):
|
||||
yield environment.get_template('article.html')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def archive_template(environment):
|
||||
yield environment.get_template('archive.html')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tags_template(environment):
|
||||
yield environment.get_template('tags.html')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tag_template(environment):
|
||||
yield environment.get_template('tag.html')
|
||||
|
||||
|
||||
def test_page(page_template):
|
||||
ctx = {
|
||||
|
||||
Reference in New Issue
Block a user