Compare commits

...
Sign in to create a new pull request.

15 commits

Author SHA1 Message Date
Python Maint
43f0269d3d Rebuilt for Python 3.14.0rc3 bytecode 2025-09-19 13:59:10 +02:00
Python Maint
086736874d Rebuilt for Python 3.14.0rc2 bytecode 2025-08-15 14:22:46 +02:00
Fedora Release Engineering
b9b9101ddb Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-25 09:21:07 +00:00
Vojtech Trefny
dad4010e50 Migrate tests from STI to TMT (#2383039) 2025-07-24 14:34:37 +02:00
Python Maint
838398badd Rebuilt for Python 3.14 2025-06-03 15:33:45 +02:00
Fedora Release Engineering
754aadf1ef Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-18 17:12:37 +00:00
Fedora Release Engineering
a845b39340 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-19 14:02:10 +00:00
Python Maint
bef98fb7bc Rebuilt for Python 3.13 2024-06-07 10:03:54 +02:00
Fedora Release Engineering
fdd1a98db3 Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-26 08:03:25 +00:00
Fedora Release Engineering
0df2504a90 Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-22 04:54:18 +00:00
Fedora Release Engineering
93fc911f47 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-21 12:16:10 +00:00
Python Maint
5b8c3398e3 Rebuilt for Python 3.12 2023-06-14 18:11:01 +02:00
Fedora Release Engineering
379f03541d Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-20 15:39:07 +00:00
vishalvvr
710734711d update tests and playbook 2022-10-13 13:12:31 +05:30
vishalvvr
55c1864859 add license source and test 2022-10-13 12:39:03 +05:30
8 changed files with 226 additions and 0 deletions

1
.fmf/version Normal file
View file

@ -0,0 +1 @@
1

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
python-pidfile-*
python-pidfile-*.tar.gz
__pycache__/

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Mosquito and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10
plans/tests.fmf Normal file
View file

@ -0,0 +1,10 @@
prepare:
how: install
package:
- python3-pidfile
discover:
how: fmf
execute:
how: tmt

91
python-pidfile.spec Normal file
View file

@ -0,0 +1,91 @@
%global module_name pidfile
%global pypi_name python-%{module_name}
Name: %{pypi_name}
Version: 3.0.0
Release: 15%{?dist}
Summary: Python context manager for managing pid files
License: MIT
URL: https://pypi.org/project/python-pidfile
Source0: %pypi_source
Source1: https://raw.githubusercontent.com/mosquito/python-pidfile/master/LICENSE
BuildArch: noarch
%global _description %{expand:
Python context manager for managing pid files.}
%description %_description
%package -n python3-%{module_name}
Summary: %{summary}
BuildRequires: python3-devel
%description -n python3-%{module_name} %_description
%prep
%autosetup %{name}-%{version}
cp -p %{SOURCE1} .
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files %{module_name}
%check
%pyproject_check_import
%files -n python3-pidfile -f %{pyproject_files}
%doc README.rst
%license LICENSE
%changelog
* Fri Sep 19 2025 Python Maint <python-maint@redhat.com> - 3.0.0-15
- Rebuilt for Python 3.14.0rc3 bytecode
* Fri Aug 15 2025 Python Maint <python-maint@redhat.com> - 3.0.0-14
- Rebuilt for Python 3.14.0rc2 bytecode
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Tue Jun 03 2025 Python Maint <python-maint@redhat.com> - 3.0.0-12
- Rebuilt for Python 3.14
* Sat Jan 18 2025 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 3.0.0-9
- Rebuilt for Python 3.13
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Wed Jun 14 2023 Python Maint <python-maint@redhat.com> - 3.0.0-5
- Rebuilt for Python 3.12
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Oct 04 2022 Vishal Vijayraghavan<vishalvvr@fedoraproject.org> - 3.0.0-3
- add license source and test
* Sun Oct 02 2022 Vishal Vijayraghavan<vishalvvr@fedoraproject.org> - 3.0.0-2
- specfile cleanup
* Tue Sep 27 2022 Vishal Vijayraghavan<vishalvvr@fedoraproject.org> - 3.0.0-1
- Initial fedora build.

1
sources Normal file
View file

@ -0,0 +1 @@
SHA512 (python-pidfile-3.0.0.tar.gz) = 82f87a2b3ac733ced78a87216f42b7fdc91f956fa9ec7e64f67ea5d53caf38652dc8b6e0518f6cfacf6bfe662c5d732f632b8f469af60555a8e6a43dbb99afbe

1
tests/test.fmf Normal file
View file

@ -0,0 +1 @@
test: python3 test_pidfile.py /tmp/test.log

98
tests/test_pidfile.py Normal file
View file

@ -0,0 +1,98 @@
import unittest
import sys
from unittest import TestCase
try:
# Python 3.x
from unittest.mock import patch, mock_open
open_name = 'builtins.open'
except ImportError:
# Python 2.7
from mock import patch, mock_open
open_name = '__builtin__.open'
import pidfile
import os
import psutil
builtins_open = open
def open_patcher(data):
def patched_open(*args, **kwargs):
if args[0] == 'pidfile':
return mock_open(read_data=data)(*args, **kwargs)
else:
return builtins_open(*args, **kwargs)
return patched_open
def open_patcher_exception():
def patched_open(*args, **kwargs):
if args[0] == 'pidfile':
mo = mock_open()
mo.return_value.read.side_effect = OSError
return mo(*args, **kwargs)
else:
return builtins_open(*args, **kwargs)
return patched_open
class PIDFileTestCase(TestCase):
@patch(open_name, new=open_patcher('1'))
@patch('os.path.exists')
def test_pidfile_not_exists(self, exists_mock):
exists_mock.return_value = False
with pidfile.PIDFile():
assert True
@patch(open_name, new=open_patcher('1'))
@patch('psutil.pid_exists')
@patch('psutil.Process')
@patch('os.path.exists')
def test_pidfile_exists_process_running(self, exists_mock, Process_mock,
pid_exists_mock):
exists_mock.return_value = True
pid_exists_mock.return_value = True
Process_mock.return_value = psutil.Process(os.getpid())
with self.assertRaises(pidfile.AlreadyRunningError):
with pidfile.PIDFile():
assert True
@patch(open_name, new=open_patcher('1'))
@patch('psutil.pid_exists')
@patch('os.path.exists')
def test_pidfile_exists_process_not_running(self, exists_mock,
pid_exists_mock):
exists_mock.return_value = True
pid_exists_mock.return_value = False
with pidfile.PIDFile():
assert True
@patch(open_name, new=open_patcher(''))
@patch('psutil.pid_exists')
@patch('os.path.exists')
def test_pidfile_exists_empty(self, exists_mock, pid_exists_mock):
exists_mock.return_value = True
pid_exists_mock.return_value = True
with pidfile.PIDFile():
assert True
@patch(open_name, new=open_patcher_exception())
@patch('psutil.pid_exists')
@patch('os.path.exists')
def test_pidfile_exists_read_fail(self, exists_mock, pid_exists_mock):
exists_mock.return_value = True
pid_exists_mock.return_value = True
with pidfile.PIDFile():
assert True
def main(out = sys.stderr, verbosity = 2):
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(sys.modules[__name__])
unittest.TextTestRunner(out, verbosity = verbosity).run(suite)
if __name__ == '__main__':
with open(sys.argv[1], 'w') as f:
main(f)