Skip to content

Commit 6eb4cf4

Browse files
Merge pull request #143 from MarketSquare/release_4.2
Release 4.2
2 parents 21f1ca6 + 968b728 commit 6eb4cf4

37 files changed

+951
-2192
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
name: Changelog CI
22

3-
on:
4-
pull_request:
5-
types: [ opened ]
3+
#on:
4+
# pull_request:
5+
# types: [ opened ]
6+
# Not working for now...
67

78
jobs:
89
build:
910
runs-on: ubuntu-latest
10-
1111
steps:
1212
- uses: actions/checkout@v2
13-
1413
- name: Run Changelog CI
15-
uses: saadmk11/changelog-ci@v1.1.2
14+
uses: saadmk11/changelog-ci@v1.2.0
1615
with:
17-
config_file: changelog-ci-config.yaml
16+
config_file: changelog-ci-config.yaml

.github/workflows/run-tests.yml

Lines changed: 72 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# This workflow runs the test suites with different versions of python
22
name: tests
33

4-
on: [push, pull_request]
4+
on:
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
59

610
jobs:
711
tests:
@@ -14,74 +18,74 @@ jobs:
1418
# pub400 closes the connection if there are too many requests coming from the same IP address
1519
max-parallel: 1
1620
matrix:
17-
python-version: ["3.8", "3.12", "3.13"]
21+
python-version: ["3.12"]
1822
os: [ubuntu-latest, windows-latest]
1923
fail-fast: false
2024

2125
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v3
24-
25-
- name: Set up python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
30-
- name: Install dependencies linux
31-
if: matrix.os == 'ubuntu-latest'
32-
run: |
33-
sudo apt-get install -y xvfb x3270 locales xterm
34-
sudo locale-gen en_US
35-
36-
- name: Install dependencies windows
37-
if: matrix.os == 'windows-latest'
38-
run: |
39-
choco install wc3270
40-
echo "C:\Program Files\wc3270" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
41-
42-
- name: Install python dependencies
43-
run: |
44-
python -m pip install -r requirements-dev.txt
45-
46-
- name: Lint
47-
run: |
48-
inv lint
49-
50-
- name: Run utests with coverage
51-
run: |
52-
coverage run --branch --source Mainframe3270/ -m pytest --verbose utest/
53-
coverage report
54-
coverage xml
55-
56-
- name: Upload unit test coverage to Codecov
57-
uses: codecov/codecov-action@v3
58-
with:
59-
files: coverage.xml
60-
flags: unit
61-
move_coverage_to_trash: true
62-
63-
- name: Run atests with coverage linux
64-
if: matrix.os == 'ubuntu-latest'
65-
run: |
66-
LANG=en_US.iso88591 xvfb-run coverage run --branch --source Mainframe3270/ -m robot $ROBOT_OPTIONS atest/
67-
coverage report
68-
coverage xml
69-
70-
- name: Run atests with coverage windows
71-
if: matrix.os == 'windows-latest'
72-
run: |
73-
coverage run --branch --source Mainframe3270/ -m robot $ROBOT_OPTIONS atest/
74-
coverage report
75-
coverage xml
76-
77-
- name: Upload acceptance tests coverage to Codecov
78-
uses: codecov/codecov-action@v3
79-
with:
80-
files: coverage.xml
81-
flags: acceptance
82-
83-
- uses: actions/upload-artifact@v4
84-
if: ${{ always() }}
85-
with:
86-
name: Tests results python${{ matrix.python-version }} - ${{ matrix.os }}
87-
path: logs/
26+
- name: Checkout repository
27+
uses: actions/checkout@v3
28+
29+
- name: Set up python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Install dependencies linux
35+
if: matrix.os == 'ubuntu-latest'
36+
run: |
37+
sudo apt-get install -y xvfb x3270 locales xterm
38+
sudo locale-gen en_US
39+
40+
- name: Install dependencies windows
41+
if: matrix.os == 'windows-latest'
42+
run: |
43+
choco install wc3270
44+
echo "C:\Program Files\wc3270" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
45+
46+
- name: Install python dependencies
47+
run: |
48+
python -m pip install -r requirements-dev.txt
49+
50+
- name: Lint
51+
run: |
52+
inv lint
53+
54+
- name: Run utests with coverage
55+
run: |
56+
coverage run --branch --source Mainframe3270/ -m pytest --verbose utest/
57+
coverage report
58+
coverage xml
59+
60+
- name: Upload unit test coverage to Codecov
61+
uses: codecov/codecov-action@v3
62+
with:
63+
files: coverage.xml
64+
flags: unit
65+
move_coverage_to_trash: true
66+
67+
- name: Run atests with coverage linux
68+
if: matrix.os == 'ubuntu-latest'
69+
run: |
70+
LANG=en_US.iso88591 xvfb-run coverage run --branch --source Mainframe3270/ -m robot $ROBOT_OPTIONS atest/
71+
coverage report
72+
coverage xml
73+
74+
- name: Run atests with coverage windows
75+
if: matrix.os == 'windows-latest'
76+
run: |
77+
coverage run --branch --source Mainframe3270/ -m robot $ROBOT_OPTIONS atest/
78+
coverage report
79+
coverage xml
80+
81+
- name: Upload acceptance tests coverage to Codecov
82+
uses: codecov/codecov-action@v3
83+
with:
84+
files: coverage.xml
85+
flags: acceptance
86+
87+
- uses: actions/upload-artifact@v4
88+
if: ${{ always() }}
89+
with:
90+
name: Tests results python${{ matrix.python-version }} - ${{ matrix.os }}
91+
path: logs/

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ log.html
1111
output.xml
1212
report.html
1313
screenshot*.html
14+
screenshot*.png
1415
atest/**/session.*3270
1516
atest/log.html
1617
atest/output.xml
@@ -36,3 +37,7 @@ htmlcov
3637

3738
# Personal test cases
3839
atest/test_with_login.robot
40+
utest/
41+
.hypothesis/
42+
.robotcode_cache/
43+
*.isorted

Mainframe3270/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import os
22
from datetime import timedelta
33
from typing import Any
4-
54
from robot.api import logger
65
from robot.api.deco import keyword
76
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
87
from robot.utils import ConnectionCache
98
from robotlibcore import DynamicCore
10-
119
from Mainframe3270.keywords import (
1210
AssertionKeywords,
1311
CommandKeywords,
@@ -150,17 +148,16 @@ def __init__(
150148
self.timeout = convert_timeout(timeout)
151149
self.wait_time = convert_timeout(wait_time)
152150
self.wait_time_after_write = convert_timeout(wait_time_after_write)
153-
self.img_folder = img_folder
154-
self._running_on_failure_keyword = False
155-
self.register_run_on_failure_keyword(run_on_failure_keyword)
156-
self.model = model
157-
self.cache = ConnectionCache()
158151
# When generating the library documentation with libdoc, BuiltIn.get_variable_value throws
159152
# a RobotNotRunningError. Therefore, we catch it here to be able to generate the documentation.
160153
try:
161-
self.output_folder = BuiltIn().get_variable_value("${OUTPUT DIR}")
154+
self.img_folder = BuiltIn().get_variable_value("${OUTPUT_DIR}")
162155
except RobotNotRunningError:
163-
self.output_folder = os.getcwd()
156+
self.img_folder = os.getcwd()
157+
self._running_on_failure_keyword = False
158+
self.register_run_on_failure_keyword(run_on_failure_keyword)
159+
self.model = model
160+
self.cache = ConnectionCache()
164161
libraries = [
165162
AssertionKeywords(self),
166163
CommandKeywords(self),

Mainframe3270/keywords/assertions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import re
22
from typing import List, Optional
3-
43
from robot.api import logger
54
from robot.api.deco import keyword
65
from robot.utils import Matcher
7-
86
from Mainframe3270.librarycomponent import LibraryComponent
97

108

Mainframe3270/keywords/commands.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import time
22
from typing import Optional, Union
3-
43
from robot.api.deco import keyword
5-
64
from Mainframe3270.librarycomponent import LibraryComponent
75
from Mainframe3270.utils import ResultMode, prepare_position_as
86

Mainframe3270/keywords/connection.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import shlex
44
from os import name as os_name
55
from typing import List, Optional, Union
6-
76
from robot.api import logger
87
from robot.api.deco import keyword
9-
108
from Mainframe3270.librarycomponent import LibraryComponent
119
from Mainframe3270.py3270 import Emulator
1210

@@ -16,10 +14,11 @@ class ConnectionKeywords(LibraryComponent):
1614
def open_connection(
1715
self,
1816
host: str,
19-
LU: Optional[str] = None,
17+
lu: Optional[str] = None,
2018
port: int = 23,
2119
extra_args: Optional[Union[List[str], os.PathLike]] = None,
2220
alias: Optional[str] = None,
21+
utf8: bool = True,
2322
) -> int:
2423
"""Create a connection to an IBM3270 mainframe with the default port 23.
2524
To establish a connection, only the hostname is required.
@@ -41,6 +40,9 @@ def open_connection(
4140
| -charset french
4241
| -port 992
4342
43+
By default, the `utf8` argument is set to `True`, which will add the `-utf8` option to the `extra_args` list.
44+
If you want to disable UTF-8 encoding, you can set the `utf8` argument to `False`.
45+
4446
Please ensure that the arguments provided are available for your specific x3270 application and version.
4547
Refer to the [https://x3270.miraheze.org/wiki/Wc3270/Command-line_options|wc3270 command line options]
4648
for a subset of available options.
@@ -53,20 +55,26 @@ def open_connection(
5355
when switching between connections using the `Switch Connection` keyword. For more information on opening
5456
and switching between multiple connections, please refer to the `Concurrent Connections` section.
5557
56-
Example:
58+
Examples:
5759
| Open Connection | Hostname |
5860
| Open Connection | Hostname | LU=LUname |
5961
| Open Connection | Hostname | port=992 |
62+
| Open Connection | Hostname | utf8=${False} |
6063
| @{extra_args} | Create List | -accepthostname | myhost.com | -cafile | ${CURDIR}/cafile.crt |
6164
| Append To List | ${extra_args} | -port | 992 |
6265
| Open Connection | Hostname | extra_args=${extra_args} |
6366
| Open Connection | Hostname | extra_args=${CURDIR}/argfile.txt |
6467
| Open Connection | Hostname | alias=my_first_connection |
6568
"""
69+
if utf8:
70+
if extra_args is None:
71+
extra_args = ["-utf8"]
72+
elif isinstance(extra_args, list):
73+
extra_args.append("-utf8")
6674
extra_args = self._process_args(extra_args)
6775
model = self._get_model_from_list_or_file(extra_args)
6876
connection = Emulator(self.visible, self.timeout, extra_args, model or self.model)
69-
host_string = f"{LU}@{host}" if LU else host
77+
host_string = f"{lu}@{host}" if lu else host
7078
if self._port_in_extra_args(extra_args):
7179
if port != 23:
7280
logger.warn(

Mainframe3270/keywords/read_write.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import time
22
from typing import Any, Optional
3-
43
from robot.api.deco import keyword
5-
from robot.libraries.BuiltIn import BuiltIn
6-
74
from Mainframe3270.librarycomponent import LibraryComponent
85
from Mainframe3270.utils import ResultMode, prepare_positions_as
96

@@ -124,12 +121,13 @@ def write(self, txt: str) -> None:
124121

125122
@keyword("Write Unicode")
126123
def write_unicode(self, txt: str) -> None:
127-
"""Send a string *and Enter* to the screen at the current cursor location.
124+
"""Send a Unicode string using the execute command String("") *and Enter* to the screen at the current
125+
cursor location.
128126
129127
Example:
130-
| Write Unicode | something |
128+
| Write Unicode | ß |
131129
"""
132-
self.mf.exec_command(f'String("{txt}")'.encode('utf-8'))
130+
self.mf.exec_command(f'String("{txt}")'.encode("utf-8"))
133131
time.sleep(self.wait_time_after_write)
134132
self.mf.send_enter()
135133

@@ -144,12 +142,12 @@ def write_bare(self, txt: str) -> None:
144142

145143
@keyword("Write Unicode Bare")
146144
def write_unicode_bare(self, txt: str) -> None:
147-
"""Send only the string to the screen at the current cursor location.
145+
"""Send only the Unicode string using the execute command String("") to the screen at the current cursor location.
148146
149147
Example:
150-
| Write Unicode Bare | something |
148+
| Write Unicode Bare | Æ |
151149
"""
152-
self.mf.exec_command(f'String("{txt}")'.encode('utf-8'))
150+
self.mf.exec_command(f'String("{txt}")'.encode("utf-8"))
153151
time.sleep(self.wait_time_after_write)
154152

155153
@keyword("Write In Position")

0 commit comments

Comments
 (0)