Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9from tsfpga.system_utils import create_file 

10from tsfpga.fix_lint import fix_trailing_whitespace, fix_tabs 

11from tsfpga.test import file_equals 

12 

13 

14def test_fix_trailing_whitespace(tmp_path): 

15 data = "Apa \nhest \nzebra" 

16 data_fixed = "Apa\nhest\nzebra" 

17 

18 file = create_file(tmp_path / "temp_file_for_test.txt", data) 

19 fix_trailing_whitespace(file) 

20 assert file_equals(file, data_fixed) 

21 

22 

23def test_fix_tabs(tmp_path): 

24 data = "Apa\thest \t zebra" 

25 data_fixed = "Apa hest zebra" 

26 file = create_file(tmp_path / "data_width_1.txt", data) 

27 fix_tabs(file, tab_width=1) 

28 assert file_equals(file, data_fixed) 

29 

30 data_fixed = "Apa hest zebra" 

31 file = create_file(tmp_path / "data_width_2.txt", data) 

32 fix_tabs(file, tab_width=2) 

33 assert file_equals(file, data_fixed)