66
77def test_rtl_config_option ():
88 """Test that RTL configuration option works in theme.conf"""
9-
9+
1010 # Read theme.conf file
1111 theme_conf_path = "src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf"
1212 with open (theme_conf_path , 'r' ) as f :
1313 theme_conf_content = f .read ()
14-
14+
1515 # Check that the RTL option is present with default False
1616 assert "script_right_to_left = False" in theme_conf_content , \
1717 "RTL configuration option should be present in theme.conf with default False"
18-
18+
1919 print ("✅ RTL configuration option found in theme.conf" )
2020
2121
2222def test_rtl_html_template ():
2323 """Test that HTML layout includes RTL support"""
24-
24+
2525 # Read layout.html file
2626 layout_html_path = "src/quantecon_book_theme/theme/quantecon_book_theme/layout.html"
2727 with open (layout_html_path , 'r' ) as f :
2828 layout_content = f .read ()
29-
29+
3030 # Check that dir="rtl" is conditionally applied
3131 assert '{% if theme_script_right_to_left %} dir="rtl"{% endif %}' in layout_content , \
3232 "HTML layout should conditionally apply dir='rtl' based on theme_script_right_to_left"
33-
33+
3434 print ("✅ RTL HTML template integration found" )
3535
3636
3737def test_rtl_python_integration ():
3838 """Test that Python code handles RTL setting"""
39-
39+
4040 # Read __init__.py file
4141 init_py_path = "src/quantecon_book_theme/__init__.py"
4242 with open (init_py_path , 'r' ) as f :
4343 init_content = f .read ()
44-
44+
4545 # Check that RTL setting is processed as boolean
4646 assert '"theme_script_right_to_left"' in init_content , \
4747 "Python code should process theme_script_right_to_left setting"
48-
48+
4949 print ("✅ RTL Python integration found" )
5050
5151
5252def test_rtl_css_styles ():
5353 """Test that RTL CSS styles are built correctly"""
54-
54+
5555 # Read built CSS file
5656 css_path = "src/quantecon_book_theme/theme/quantecon_book_theme/static/styles/quantecon-book-theme.css"
5757 with open (css_path , 'r' ) as f :
5858 css_content = f .read ()
59-
59+
6060 # Check that RTL styles are present
6161 assert '[dir=rtl]' in css_content , \
6262 "Built CSS should contain [dir=rtl] selector"
63-
63+
6464 # Check for some key RTL adjustments
6565 assert 'text-align:right' in css_content , \
6666 "RTL CSS should include right text alignment"
67-
67+
6868 print ("✅ RTL CSS styles found in built stylesheet" )
6969
7070
7171def test_rtl_scss_source ():
7272 """Test that RTL SCSS source file exists and is included"""
73-
73+
7474 # Check that RTL SCSS file exists
7575 rtl_scss_path = "src/quantecon_book_theme/assets/styles/_rtl.scss"
7676 with open (rtl_scss_path , 'r' ) as f :
7777 rtl_scss_content = f .read ()
78-
78+
7979 # Check for key RTL styles
8080 assert '[dir="rtl"]' in rtl_scss_content , \
8181 "RTL SCSS should contain [dir='rtl'] selector"
82-
82+
8383 # Check main index.scss includes RTL
8484 index_scss_path = "src/quantecon_book_theme/assets/styles/index.scss"
8585 with open (index_scss_path , 'r' ) as f :
8686 index_content = f .read ()
87-
87+
8888 assert '@forward "rtl"' in index_content , \
8989 "Main SCSS should forward RTL styles"
90-
90+
9191 print ("✅ RTL SCSS source and integration found" )
9292
9393
9494if __name__ == "__main__" :
9595 print ("Running RTL configuration tests...\n " )
96-
96+
9797 try :
9898 test_rtl_config_option ()
9999 test_rtl_html_template ()
100100 test_rtl_python_integration ()
101101 test_rtl_css_styles ()
102102 test_rtl_scss_source ()
103-
103+
104104 print ("\n 🎉 All RTL tests passed!" )
105105 print ("\n RTL support is properly implemented with:" )
106106 print (" - Configuration option: script_right_to_left = False (default)" )
107107 print (" - HTML template integration for dir='rtl' attribute" )
108108 print (" - Python code processing RTL setting as boolean" )
109109 print (" - Comprehensive RTL CSS styles for layout adjustments" )
110110 print (" - Proper SCSS source organization and compilation" )
111-
111+
112112 except Exception as e :
113113 print (f"❌ Test failed: { e } " )
114- exit (1 )
114+ exit (1 )
0 commit comments