Page MenuHomeSoftware Heritage

conftest.py
No OneTemporary

conftest.py

# Copyright (C) 2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
import json
import os
def pytest_configure(config):
# Small hack in order to be able to run the unit tests
# without static assets generated by webpack.
# Those assets are not really needed for the Python tests
# but the django templates will fail to load due to missing
# generated file webpack-stats.json describing the js and css
# files to include.
# So generate a dummy webpack-stats.json file to overcome
# that issue.
test_dir = os.path.dirname(__file__)
static_dir = os.path.join(test_dir, '../static')
webpack_stats = os.path.join(static_dir, 'webpack-stats.json')
if os.path.exists(webpack_stats):
return
bundles_dir = os.path.join(test_dir, '../assets/src/bundles')
_, dirs, _ = next(os.walk(bundles_dir))
mock_webpack_stats = {
'status': 'done',
'publicPath': '/static',
'chunks': {}
}
for bundle in dirs:
asset = 'js/%s.js' % bundle
mock_webpack_stats['chunks'][bundle] = [{
'name': asset,
'publicPath': '/static/%s' % asset,
'path': os.path.join(static_dir, asset)
}]
with open(webpack_stats, 'w') as outfile:
json.dump(mock_webpack_stats, outfile)

File Metadata

Mime Type
text/x-python
Expires
Tue, Jun 3, 7:35 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3286855

Event Timeline