Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/dev/test/trac_server.py
8815 views
1
r"""
2
Trac Server for Doctesting
3
4
This module provides a fake trac server which can be used for doctesting.
5
6
AUTHORS:
7
8
- Julian Rueth: initial version
9
10
"""
11
#*****************************************************************************
12
# Copyright (C) 2013 Julian Rueth <[email protected]>
13
#
14
# Distributed under the terms of the GNU General Public License (GPL)
15
# as published by the Free Software Foundation; either version 2 of
16
# the License, or (at your option) any later version.
17
# http://www.gnu.org/licenses/
18
#*****************************************************************************
19
20
class DoctestTracServer(object):
21
r"""
22
A trac "server" which can be shared among instances of
23
:class:`trac_interface.DoctestTracInterface` to keep track of tickets
24
during doctesting.
25
26
EXAMPLES::
27
28
sage: from sage.dev.test.trac_server import DoctestTracServer
29
sage: DoctestTracServer()
30
<sage.dev.test.trac_server.DoctestTracServer object at 0x...>
31
32
"""
33
def __init__(self):
34
r"""
35
Initialization.
36
37
TESTS::
38
39
sage: from sage.dev.test.trac_server import DoctestTracServer
40
sage: type(DoctestTracServer())
41
<class 'sage.dev.test.trac_server.DoctestTracServer'>
42
43
"""
44
self.tickets = {}
45
from sage.dev.test.user_interface import DoctestUserInterface
46
from sage.dev.test.config import DoctestConfig
47
from sage.dev.sagedev import MASTER_BRANCH
48
from sage.dev.git_interface import GitInterface
49
config = DoctestConfig()
50
self.git = GitInterface(config['git'], DoctestUserInterface(config['UI']))
51
52
import os
53
old_cwd = os.getcwd()
54
os.chdir(config['git']['src'])
55
try:
56
self.git.super_silent.commit(allow_empty=True, message='initial commit')
57
if MASTER_BRANCH != "master": self.git.super_silent.checkout("-b", MASTER_BRANCH)
58
from sage.env import SAGE_VERSION
59
self.git.super_silent.tag(SAGE_VERSION)
60
finally:
61
os.chdir(old_cwd)
62
63
class Ticket(object):
64
r"""
65
Container for a ticket of a :class:`DoctestTracServer`.
66
67
EXAMPLES::
68
69
sage: from sage.dev.test.trac_server import Ticket
70
sage: Ticket(1, "summary", "description", {})
71
<sage.dev.test.trac_server.Ticket object at 0x...>
72
73
"""
74
def __init__(self, ticket, summary, description, attributes):
75
r"""
76
Initialization.
77
78
TESTS::
79
80
sage: from sage.dev.test.trac_server import Ticket
81
sage: type(Ticket(1, "summary", "description", {}))
82
<class 'sage.dev.test.trac_server.Ticket'>
83
84
"""
85
attributes['summary'] = summary
86
attributes['description'] = description
87
self.id = ticket
88
self.attributes = attributes
89
self.time_created = 'not implemented'
90
self.time_changed = 'not implemented'
91
self.comments = []
92
self.attachments = {}
93
94