File: test_licenses.py

package info (click to toggle)
python-b2sdk 2.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,228 kB
  • sloc: python: 32,094; sh: 13; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
######################################################################
#
# File: test/static/test_licenses.py
#
# Copyright 2020 Backblaze Inc. All Rights Reserved.
#
# License https://www.backblaze.com/using_b2_code.html
#
######################################################################
from __future__ import annotations

from glob import glob
from itertools import islice

import pytest


def test_files_headers():
    for file in glob('**/*.py', recursive=True):
        with open(file) as fd:
            file = file.replace(
                '\\', '/'
            )  # glob('**/*.py') on Windows returns "b2\bucket.py" (wrong slash)
            head = ''.join(islice(fd, 9))
            if 'All Rights Reserved' not in head:
                pytest.fail(f'Missing "All Rights Reserved" in the header in: {file}')
            if file not in head:
                pytest.fail(f'Wrong file name in the header in: {file}')